Book 3342
Book 3342
Book 3342
Overview
Always On Availability Groups
sys.dm_hadr_auto_page_repair
sys.dm_hadr_availability_group_states
sys.dm_hadr_availability_replica_cluster_nodes
sys.dm_hadr_availability_replica_cluster_states
sys.dm_hadr_availability_replica_states
sys.dm_hadr_cluster
sys.dm_hadr_cluster_members
sys.dm_hadr_cluster_networks
sys.dm_hadr_database_replica_cluster_states
sys.dm_hadr_database_replica_states
sys.dm_hadr_instance_node_map
sys.dm_hadr_name_id_map
sys.dm_tcp_listener_states
Change Data Capture
sys.dm_cdc_errors
sys.dm_cdc_log_scan_sessions
Change tracking
sys.dm_tran_commit_table
Common Language Runtime
sys.dm_clr_appdomains
sys.dm_clr_loaded_assemblies
sys.dm_clr_properties
sys.dm_clr_tasks
Database
sys.dm_db_file_space_usage
sys.dm_db_fts_index_physical_stats
sys.dm_db_log_info
sys.dm_db_log_space_usage
sys.dm_db_log_stats
sys.dm_db_objects_impacted_on_version_change (Azure SQL Database)
sys.dm_db_page_info
sys.dm_db_partition_stats
sys.dm_db_persisted_sku_features
sys.dm_db_session_space_usage
sys.dm_db_task_space_usage
sys.dm_db_uncontained_entities
sys.dm_db_wait_stats (Azure SQL Database)
sys.dm_operation_status (Azure SQL Database)
sys.dm_database_copies (Azure SQL Database)
sys.dm_db_resource_stats (Azure SQL Database)
Database Mirroring
sys.dm_db_mirroring_auto_page_repair
sys.dm_db_mirroring_connections
Execution
sys.dm_exec_background_job_queue
sys.dm_exec_background_job_queue_stats
sys.dm_exec_cached_plan_dependent_objects
sys.dm_exec_cached_plans
sys.dm_exec_compute_node_errors
sys.dm_exec_compute_node_status
sys.dm_exec_compute_nodes
sys.dm_exec_connections
sys.dm_exec_cursors
sys.dm_exec_describe_first_result_set
sys.dm_exec_describe_first_result_set_for_object
sys.dm_exec_distributed_request_steps
sys.dm_exec_distributed_requests
sys.dm_exec_distributed_sql_requests
sys.dm_exec_dms_services
sys.dm_exec_dms_workers
sys.dm_exec_external_operations
sys.dm_exec_external_work
sys.dm_exec_function_stats
sys.dm_exec_input_buffer
sys.dm_exec_plan_attributes
sys.dm_exec_procedure_stats
sys.dm_exec_query_memory_grants
sys.dm_exec_query_optimizer_info
sys.dm_exec_query_optimizer_memory_gateways
sys.dm_exec_query_parallel_workers
sys.dm_exec_query_plan
sys.dm_exec_query_profiles
sys.dm_exec_query_resource_semaphores
sys.dm_exec_query_statistics_xml
sys.dm_exec_query_stats
sys.dm_exec_requests
sys.dm_exec_session_wait_stats
sys.dm_exec_sessions
sys.dm_exec_sql_text
sys.dm_exec_text_query_plan
sys.dm_exec_trigger_stats
sys.dm_exec_valid_use_hints
sys.dm_exec_xml_handles
sys.dm_external_script_execution_stats
sys.dm_external_script_requests
Extended Events
sys.dm_xe_database_sessions (Azure SQL Database)
sys.dm_xe_database_session_targets (Azure SQL Database)
sys.dm_xe_database_session_object_columns (Azure SQL Database)
sys.dm_xe_database_session_events (Azure SQL Database)
sys.dm_xe_database_session_event_actions (Azure SQL Database)
sys.dm_xe_map_values
sys.dm_xe_object_columns
sys.dm_xe_objects
sys.dm_xe_packages
sys.dm_xe_session_event_actions
sys.dm_xe_session_events
sys.dm_xe_session_object_columns
sys.dm_xe_session_targets
sys.dm_xe_sessions
Filestream and FileTable
sys.dm_filestream_file_io_handles
sys.dm_filestream_file_io_requests
sys.dm_filestream_non_transacted_handles
Full-Text Search and Semantic Search
sys.dm_fts_active_catalogs
sys.dm_fts_fdhosts
sys.dm_fts_index_keywords
sys.dm_fts_index_keywords_by_document
sys.dm_fts_index_keywords_by_property
sys.dm_fts_index_keywords_position_by_document
sys.dm_fts_index_population
sys.dm_fts_memory_buffers
sys.dm_fts_memory_pools
sys.dm_fts_outstanding_batches
sys.dm_fts_parser
sys.dm_fts_population_ranges
sys.dm_fts_semantic_similarity_population
Geo-Replication (Azure SQL Database)
sys.geo_replication_links (Azure SQL Database)
sys.dm_geo_replication_link_status (Azure SQL Database)
sys.dm_continuous_copy_status (Azure SQL Database)
Index
sys.dm_column_store_object_pool
sys.dm_column_store_object_pool
sys.dm_db_column_store_row_group_operational_stats
sys.dm_db_column_store_row_group_physical_stats
sys.dm_db_index_operational_stats
sys.dm_db_index_physical_stats
sys.dm_db_index_usage_stats
sys.dm_db_missing_index_columns
sys.dm_db_missing_index_details
sys.dm_db_missing_index_groups
sys.dm_db_missing_index_group_stats
IO
sys.dm_io_backup_tapes
sys.dm_io_cluster_shared_drives
sys.dm_io_pending_io_requests
sys.dm_io_virtual_file_stats
sys.dm_io_cluster_valid_path_names
Memory-Optimized Table
sys.dm_db_xtp_checkpoint_stats
sys.dm_db_xtp_checkpoint_files
sys.dm_db_xtp_gc_cycle_stats
sys.dm_db_xtp_hash_index_stats
sys.dm_db_xtp_index_stats
sys.dm_db_xtp_memory_consumers
sys.dm_db_xtp_merge_requests
sys.dm_db_xtp_nonclustered_index_stats
sys.dm_db_xtp_object_stats
sys.dm_db_xtp_table_memory_stats
sys.dm_db_xtp_transactions
sys.dm_xtp_gc_queue_stats
sys.dm_xtp_gc_stats
sys.dm_xtp_system_memory_consumers
sys.dm_xtp_transaction_stats
Object
sys.dm_db_incremental_stats_properties
sys.dm_db_stats_histogram
sys.dm_db_stats_properties
sys.dm_sql_referenced_entities
sys.dm_sql_referencing_entities
Query Notifications
sys.dm_qn_subscriptions
Replication
sys.dm_repl_articles
sys.dm_repl_schemas
sys.dm_repl_tranhash
sys.dm_repl_traninfo
Resource Governor
sys.dm_resource_governor_configuration
sys.dm_resource_governor_external_resource_pool_affinity
sys.dm_resource_governor_external_resource_pools
sys.dm_resource_governor_resource_pool_affinity
sys.dm_resource_governor_resource_pools
sys.dm_resource_governor_resource_pool_volumes
sys.dm_resource_governor_workload_groups
Security-Related
sys.dm_audit_actions
sys.dm_audit_class_type_map
sys.dm_cryptographic_provider_algorithms
sys.dm_cryptographic_provider_keys
sys.dm_cryptographic_provider_properties
sys.dm_cryptographic_provider_sessions
sys.dm_database_encryption_keys
sys.dm_server_audit_status
Server-Related
sys.dm_server_memory_dumps
sys.dm_server_services
sys.dm_server_registry
Service Broker
sys.dm_broker_activated_tasks
sys.dm_broker_connections
sys.dm_broker_forwarded_messages
sys.dm_broker_queue_monitors
Spatial data
sys.dm_db_objects_disabled_on_compatibility_level_change
SQL Data Warehouse and Parallel Data Warehouse
sys.dm_pdw_component_health_active_alerts
sys.dm_pdw_component_health_alerts
sys.dm_pdw_component_health_status
sys.dm_pdw_diag_processing_stats
sys.dm_pdw_dms_cores
sys.dm_pdw_dms_external_work
sys.dm_pdw_dms_workers
sys.dm_pdw_errors
sys.dm_pdw_exec_connections
sys.dm_pdw_exec_requests
sys.dm_pdw_exec_sessions
sys.dm_pdw_hadoop_operations
sys.dm_pdw_lock_waits
sys.dm_pdw_network_credentials
sys.dm_pdw_node_status
sys.dm_pdw_nodes
sys.dm_pdw_nodes_database_encryption_keys
sys.dm_pdw_os_event_logs
sys.dm_pdw_os_performance_counters
sys.dm_pdw_os_threads
sys.dm_pdw_query_stats_xe
sys.dm_pdw_query_stats_xe_file
sys.dm_pdw_request_steps
sys.dm_pdw_resource_waits
sys.dm_pdw_sql_requests
sys.dm_pdw_sys_info
sys.dm_pdw_wait_stats
sys.dm_pdw_waits
SQL Server Operating System
sys.dm_os_buffer_descriptors
sys.dm_os_buffer_pool_extension_configuration
sys.dm_os_child_instances
sys.dm_os_cluster_nodes
sys.dm_os_cluster_properties
sys.dm_os_dispatcher_pools
sys.dm_os_host_info
sys.dm_os_hosts
sys.dm_os_job_object
sys.dm_os_latch_stats
sys.dm_os_loaded_modules
sys.dm_os_memory_brokers
sys.dm_os_memory_cache_clock_hands
sys.dm_os_memory_cache_counters
sys.dm_os_memory_cache_entries
sys.dm_os_memory_cache_hash_tables
sys.dm_os_memory_clerks
sys.dm_os_memory_nodes
sys.dm_os_memory_objects
sys.dm_os_memory_pools
sys.dm_os_nodes
sys.dm_os_performance_counters
sys.dm_os_process_memory
sys.dm_os_schedulers
sys.dm_os_server_diagnostics_log_configurations
sys.dm_os_stacks
sys.dm_os_sys_info
sys.dm_os_sys_memory
sys.dm_os_tasks
sys.dm_os_threads
sys.dm_os_virtual_address_dump
sys.dm_os_volume_stats
sys.dm_os_waiting_tasks
sys.dm_os_wait_stats
sys.dm_os_windows_info
sys.dm_os_workers
Stretch Database
sys.dm_db_rda_migration_status
sys.dm_db_rda_schema_update_status
Transactions
sys.dm_tran_active_snapshot_database_transactions
sys.dm_tran_active_transactions
sys.dm_tran_current_snapshot
sys.dm_tran_current_transaction
sys.dm_tran_database_transactions
sys.dm_tran_locks
sys.dm_tran_session_transactions
sys.dm_tran_top_version_generators
sys.dm_tran_transactions_snapshot
sys.dm_tran_version_store
sys.dm_tran_version_store_space_usage
System Dynamic Management Views
11/14/2018 • 3 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2008) Azure SQL Database Azure SQL Data
Warehouse Parallel Data Warehouse
Dynamic management views and functions return server state information that can be used to
monitor the health of a server instance, diagnose problems, and tune performance.
IMPORTANT
Dynamic management views and functions return internal, implementation-specific state data. Their
schemas and the data they return may change in future releases of SQL Server. Therefore, dynamic
management views and functions in future releases may not be compatible with the dynamic management
views and functions in this release. For example, in future releases of SQL Server, Microsoft may augment
the definition of any dynamic management view by adding columns to the end of the column list. We
recommend against using the syntax SELECT * FROM dynamic_management_view_name in production code
because the number of columns returned might change and break your application.
Required Permissions
To query a dynamic management view or function requires SELECT permission on object and
VIEW SERVER STATE or VIEW DATABASE STATE permission. This lets you selectively restrict
access of a user or login to dynamic management views and functions. To do this, first create the
user in master and then deny the user SELECT permission on the dynamic management views or
functions that you do not want them to access. After this, the user cannot select from these dynamic
management views or functions, regardless of database context of the user.
NOTE
Because DENY takes precedence, if a user has been granted VIEW SERVER STATE permissions but denied
VIEW DATABASE STATE permission, the user can see server-level information, but not database-level
information.
In This Section
Dynamic management views and functions have been organized into the following categories.
Change Data Capture Related Dynamic Management Object Related Dynamic Management Views and
Views (Transact-SQL) Functions (Transact-SQL)
Change Tracking Related Dynamic Management Query Notifications Related Dynamic Management
Views Views (Transact-SQL)
Common Language Runtime Related Dynamic Replication Related Dynamic Management Views
Management Views (Transact-SQL) (Transact-SQL)
Database Mirroring Related Dynamic Management Resource Governor Related Dynamic Management
Views (Transact-SQL) Views (Transact-SQL)
Database Related Dynamic Management Views Security-Related Dynamic Management Views and
(Transact-SQL) Functions (Transact-SQL)
Execution Related Dynamic Management Views and Server-Related Dynamic Management Views and
Functions (Transact-SQL) Functions (Transact-SQL)
Extended Events Dynamic Management Views Service Broker Related Dynamic Management Views
(Transact-SQL)
Filestream and FileTable Dynamic Management Views Spatial Data Related Dynamic Management Views
(Transact-SQL) and Functions (Transact-SQL)
Full-Text Search and Semantic Search Dynamic SQL Data Warehouse and Parallel Data Warehouse
Management Views and Functions (Transact-SQL) Dynamic Management Views (Transact-SQL)
Geo-Replication Dynamic Management Views and SQL Server Operating System Related Dynamic
Functions (Azure SQL Database) Management Views (Transact-SQL)
Index Related Dynamic Management Views and Stretch Database Dynamic Management Views
Functions (Transact-SQL) (Transact-SQL)
I O Related Dynamic Management Views and Transaction Related Dynamic Management Views and
Functions (Transact-SQL) Functions (Transact-SQL)
See Also
GRANT Server Permissions (Transact-SQL )
GRANT Database Permissions (Transact-SQL )
System Views (Transact-SQL )
Always On Availability Groups Dynamic Management
Views - Functions
10/1/2018 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2012) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
This section contains the dynamic management views and functions that are related to Always On availability
groups.
In This Section
sys.dm_hadr_auto_page_repair sys.dm_hadr_cluster_networks
sys.dm_hadr_availability_group_states sys.dm_hadr_database_replica_cluster_states
sys.dm_hadr_availability_replica_cluster_nodes sys.dm_hadr_database_replica_states
sys.dm_hadr_availability_replica_cluster_states sys.dm_hadr_instance_node_map
sys.dm_hadr_availability_replica_states sys.dm_hadr_name_id_map
sys.dm_hadr_cluster sys.dm_tcp_listener_states
sys.dm_hadr_cluster_members
See Also
AlwaysOn Availability Groups (SQL Server)
AlwaysOn Availability Groups Catalog Views (Transact-SQL )
Monitor Availability Groups (Transact-SQL )
sys.dm_hadr_auto_page_repair (Transact-SQL)
10/1/2018 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2012) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
Returns a row for every automatic page-repair attempt on any availability database on an availability replica that is
hosted for any availability group by the server instance. This view contains rows for the latest automatic page-
repair attempts on a given primary or secondary database, with a maximum of 100 rows per database. As soon as
a database reaches the maximum, the row for its next automatic page-repair attempt replaces one of the existing
entries.
The following table defines the meaning of the various columns:
2 = Bad checksum
3 = Torn page
COLUMN NAME DATA TYPE DESCRIPTION
Security
Permissions
Requires VIEW SERVER STATE permission on the server.
See Also
Automatic Page Repair (Availability Groups: Database Mirroring)
suspect_pages (Transact-SQL )
Manage the suspect_pages Table (SQL Server)
sys.dm_hadr_availability_group_states (Transact-SQL)
10/1/2018 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2012) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
Returns a row for each Always On availability group that possesses an availability replica on the local instance of
SQL Server. Each row displays the states that define the health of a given availability group.
NOTE
To obtain the complete list of, query the sys.availability_groups catalog view.
0 = In progress
1 = Online
NULL
ONLINE_IN_PROGRESS
ONLINE
NULL
COLUMN NAME DATA TYPE DESCRIPTION
0 = In progress
1 = Online
NULL
ONLINE_IN_PROGRESS
ONLINE
NULL
NOT_HEALTHY
PARTIALLY_HEALTHY
HEALTHY
Security
Permissions
Requires VIEW SERVER STATE permission on the server.
See Also
Monitor Availability Groups (Transact-SQL )
Always On Availability Groups (SQL Server)
Always On Availability Groups Dynamic Management Views and Functions (Transact-SQL )
sys.dm_hadr_availability_replica_cluster_nodes
(Transact-SQL)
10/1/2018 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2012) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
Returns a row for every availability replica (regardless of join state) of the Always On availability groups in the
Windows Server Failover Clustering (WSFC ) cluster.
Security
Permissions
Requires VIEW SERVER STATE permission on the server.
See Also
Monitor Availability Groups (Transact-SQL )
Overview of Always On Availability Groups (SQL Server)
sys.dm_hadr_availability_replica_cluster_states
(Transact-SQL)
10/1/2018 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2012) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
Returns a row for each Always On availability replica (regardless of its join state) of all Always On availability
groups (regardless of replica location) in the Windows Server Failover Clustering (WSFC ) cluster.
JOINED_STANDALONE_INSTANCE
JOINED_FAILOVER_CLUSTER_INSTANCE
Security
Permissions
Requires VIEW SERVER STATE permission on the server.
See Also
Monitor Availability Groups (Transact-SQL )
sys.dm_hadr_availability_replica_states (Transact-SQL)
10/1/2018 • 4 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2012) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
Returns a row for each local replica and a row for each remote replica in the same Always On availability group as
a local replica. Each row contains information about the state of a given replica.
IMPORTANT
To obtain information about every replica in a given availability group, query sys.dm_hadr_availability_replica_states on
the server instance that is hosting the primary replica. When queried on a server instance that is hosting a secondary replica
of an availability group, this dynamic management view returns only local information for the availability group.
0 = Resolving
1 = Primary
2 = Secondary
RESOLVING
PRIMARY
SECONDARY
0 = Pending failover
1 = Pending
2 = Online
3 = Offline
4 = Failed
5 = Failed, no quorum
PENDING_FAILOVER
PENDING
ONLINE
OFFLINE
FAILED
FAILED_NO_QUORUM
NULL
COLUMN NAME DATA TYPE DESCRIPTION
NULL : is_local = 0
ONLINE_IN_PROGRESS
ONLINE
NULL
NOT_HEALTHY
PARTIALLY_HEALTHY
HEALTHY
1 : Connected.
DISCONNECTED
CONNECTED
OFFLINE All configuration data for the availability replica has been
updated on WSFC cluster and, also, in local metadata, but the
availability group currently lacks a primary replica.
FAILED_NO_QUORUM The local WSFC node does not have quorum. This is an
inferred state.
PRIMARY: When an availability replica is performing the PRIMARY role, it is currently the primary replica. The
possible operational states are as shown in the following table.
SECONDARY: When an availability replica is performing the SECONDARY role, it is currently a secondary
replica. The possible operational states are as shown in the table below.
Security
Permissions
Requires VIEW SERVER STATE permission on the server.
See Also
Overview of Always On Availability Groups (SQL Server)
Monitor Availability Groups (Transact-SQL )
sys.dm_hadr_cluster (Transact-SQL)
10/1/2018 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2012) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
If the Windows Server Failover Clustering (WSFC ) node that hosts an instance of SQL Server that is enabled for
Always On availability groups has WSFC quorum, sys.dm_hadr_cluster returns a row that exposes the cluster
name and information about the quorum. If the WSFC node has no quorum, no row is returned.
TIP
Beginning in SQL Server 2014 (12.x), this dynamic management view supports Always On Failover Cluster Instances in
addition to Always On Availability Groups.
NODE_MAJORITY
NODE_AND_DISK_MAJORITY
NODE_AND_FILE_SHARE_MAJORITY
NO_MAJORITY:_DISK_ONLY
1 = Normal quorum
2 = Forced quorum
UNKNOWN_QUORUM_STATE
NORMAL_QUORUM
FORCED_QUORUM
Permissions
Requires VIEW SERVER STATE permission on the server.
See Also
Always On Availability Groups Dynamic Management Views and Functions (Transact-SQL )
Always On Availability Groups Catalog Views (Transact-SQL )
Monitor Availability Groups (Transact-SQL )
sys.dm_hadr_cluster_members (Transact-SQL )
sys.dm_hadr_cluster_members (Transact-SQL)
10/1/2018 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2012) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
If the WSFC node that hosts a local instance of SQL Server that is enabled for Always On availability groups has
WSFC quorum, returns a row for each of the members that constitute the quorum and the state of each of them.
This includes of all nodes in the cluster (returned with CLUSTER_ENUM_NODE type by the Clusterenum
function) and the disk or file-share witness, if any. The row returned for a given member contains information
about the state of that member. For example, for a five node cluster with majority node quorum in which one node
is down, when sys.dm_hadr_cluster_members is queried from a server instance that is that is enabled for Always
On availability groups that resides on a node with quorum, sys.dm_hadr_cluster_members reflects the state of
the down node as "NODE_DOWN".
If the WSFC node has no quorum, no rows are returned.
Use this dynamic management view to answer the following questions:
What nodes are currently running on the WSFC cluster?
How many more failures can the WSFC cluster tolerate before losing quorum in a majority-node case?
TIP
Beginning in SQL Server 2014 (12.x), this dynamic management view supports Always On Failover Cluster Instances
in addition to Always On Availability Groups.
0 = WSFC node
1 = Disk witness
CLUSTER_NODE
DISK_WITNESS
FILE_SHARE_WITNESS
COLUMN NAME DATA TYPE DESCRIPTION
0 = Offline
1 = Online
UP
DOWN
Permissions
Requires VIEW SERVER STATE permission on the server.
Examples
See Also
Always On Availability Groups Dynamic Management Views and Functions (Transact-SQL )
Always On Availability Groups Catalog Views (Transact-SQL )
Monitor Availability Groups (Transact-SQL )
AlwaysOn Availability Groups (SQL Server)
sys.dm_hadr_cluster_networks (Transact-SQL)
10/1/2018 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2012) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
Returns a row for every WSFC cluster member that is participating in an availability group's subnet configuration.
You can use this dynamic management view to validate the network virtual IP that is configured for each
availability replica.
Primary key: member_name + network_subnet_IP + network_subnet_prefix_length
TIP
Beginning in SQL Server 2014 (12.x), this dynamic management view supports Always On Failover Cluster Instances in
addition to Always On Availability Groups.
0 = Private
1 = Public
COLUMN NAME DATA TYPE DESCRIPTION
1 = IPv4
0 = IPv6
Security
Permissions
Requires VIEW SERVER STATE permission on the server.
See Also
Failover Clustering and Always On Availability Groups (SQL Server)
Monitor Availability Groups (Transact-SQL )
sys.dm_os_cluster_nodes (Transact-SQL )
Querying the SQL Server System Catalog FAQ
Catalog Views (Transact-SQL )
sys.dm_hadr_database_replica_cluster_states
(Transact-SQL)
10/1/2018 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2012) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
Returns a row containing information intended to provide you with insight into the health of the availability
databases in the Always On availability groups in each Always On availability group on the Windows Server
Failover Clustering (WSFC ) cluster. Query sys.dm_hadr_database_replica_states to answer the following
questions:
Are all databases in an availability group ready for a failover?
After a forced failover, has a secondary database suspended itself locally and acknowledged its suspended
state to the new primary replica?
If the primary replica is currently unavailable, which secondary replica would allow the minimum data loss if
it becomes the primary replica?
When the value of the sys.databases log_reuse_wait_desc column is "AVAILABILITY_REPLICA", which
secondary replica in an availability group is holding up log truncation on a given primary database?
1 = HADR_SYNCHRONIZED_
SUSPENDED. When a forced failover
completes, each of the secondary
databases is set to
HADR_SYNCHONIZED_SUSPENDED and
remains in this state until the new
primary replica receives an
acknowledgement from that secondary
database to the SUSPEND message.
Security
Permissions
Requires VIEW SERVER STATE permission on the server.
See Also
Always On Availability Groups Dynamic Management Views and Functions (Transact-SQL )
Always On Availability Groups Catalog Views (Transact-SQL )
Monitor Availability Groups (Transact-SQL )
Always On Availability Groups (SQL Server)
sys.dm_hadr_database_replica_states (Transact-SQL )
sys.dm_hadr_database_replica_states (Transact-SQL)
11/19/2018 • 10 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2012) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
Returns a row for each database that is participating in an Always On availability group for which the local
instance of SQL Server is hosting an availability replica. This dynamic management view exposes state
information on both the primary and secondary replicas. On a secondary replica, this view returns a row for every
secondary database on the server instance. On the primary replica, this view returns a row for each primary
database and an additional row for the corresponding secondary database.
IMPORTANT
Depending on the action and higher-level states, database-state information may be unavailable or out of date.
Furthermore, the values have only local relevance. For example, on the primary replica, the value of the last_hardened_lsn
column reflects the information about a given secondary database that is currently available to the primary replica, not the
actual hardened LSN value that the secondary replica might have currently.
NOT SYNCHRONIZING
SYNCHRONIZING
SYNCHRONIZED
REVERTING
INITIALIZING
2 = Healthy. A database on an
synchronous-commit availability replica
is considered healthy if
synchronization_state is 2
(SYNCHRONIZED), and a database on
an asynchronous-commit availability
replica is considered healthy if
synchronization_state is 1
(SYNCHRONIZING).
COLUMN NAME DATA TYPE DESCRIPTION (ON PRIMARY REPLICA)
NOT_HEALTHY
PARTIALLY_HEALTHY
HEALTHY
1 = Restoring
2 = Recovering
3 = Recovery pending
4 = Suspect
5 = Emergency
6 = Offline
ONLINE
RESTORING
RECOVERING
RECOVERY_PENDING
SUSPECT
EMERGENCY
OFFLINE
0 = Resumed
1 = Suspended
COLUMN NAME DATA TYPE DESCRIPTION (ON PRIMARY REPLICA)
0 = User action
2 = Redo
3 = Capture
4 = Apply
5 = Restart
6 = Undo
7 = Revalidation
SUSPEND_FROM_USER = A user
manually suspended data movement
SUSPEND_FROM_PARTNER = The
database replica is suspended after a
forced failover
SUSPEND_FROM_REDO = An error
occurred during the redo phase
SUSPEND_FROM_APPLY = An error
occurred when writing the log to file
(see error log)
SUSPEND_FROM_CAPTURE = An error
occurred while capturing log on the
primary replica
SUSPEND_FROM_RESTART = The
database replica was suspended before
the database was restarted (see error
log)
SUSPEND_FROM_UNDO = An error
occurred during the undo phase (see
error log)
SUSPEND_FROM_REVALIDATION =
Log change mismatch is detected on
reconnection (see error log)
SUSPEND_FROM_XRF_UPDATE =
Unable to find the common log point
(see error log)
COLUMN NAME DATA TYPE DESCRIPTION (ON PRIMARY REPLICA)
last_sent_time datetime Time when the last log block was sent.
On an asynchronous-commit primary
database or on a synchronous-commit
database whose current policy is
"delay", the value is NULL. For other
synchronous-commit primary
databases, last_hardened_lsn indicates
the minimum of the hardened LSN
across all the secondary databases.
Security
Permissions
Requires VIEW SERVER STATE permission on the server.
See Also
Always On Availability Groups (SQL Server)
Monitor Availability Groups (Transact-SQL )
sys.dm_hadr_instance_node_map (Transact-SQL)
10/1/2018 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2012) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
For every instance of SQL Server that hosts an availability replica that is joined to its Always On availability group,
returns the name of the Windows Server Failover Clustering (WSFC ) node that hosts the server instance. This
dynamic management view has the following uses:
This dynamic management view is useful for detecting an availability group with multiple availability
replicas that are hosted on the same WSFC node, which is an unsupported configuration that could occur
after an FCI failover if the availability group is incorrectly configured. For more information, see Failover
Clustering and Always On Availability Groups (SQL Server).
When multiple SQL Server instances are hosted on the same WSFC node, the Resource DLL uses this
dynamic management view to determine the instance of SQL Server to connect to.
Permissions
Requires VIEW SERVER STATE permission on the server.
See Also
Always On Availability Groups Dynamic Management Views and Functions (Transact-SQL )
Always On Availability Groups Catalog Views (Transact-SQL )
Monitor Availability Groups (Transact-SQL )
Always On Availability Groups (SQL Server)
sys.dm_hadr_name_id_map (Transact-SQL)
10/1/2018 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2012) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
Shows the mapping of Always On availability groups that the current instance of SQL Server has joined to three
unique IDs: an availability group ID, a WSFC resource ID, and a WSFC Group ID. The purpose of this mapping is
to handle the scenario in which the WSFC resource/group is renamed.
Permissions
Requires VIEW SERVER STATE permission on the server.
See Also
Always On Availability Groups Dynamic Management Views and Functions (Transact-SQL )
Always On Availability Groups Catalog Views (Transact-SQL )
Monitor Availability Groups (Transact-SQL )
Always On Availability Groups (SQL Server)
sys.dm_tcp_listener_states (Transact-SQL)
10/1/2018 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2012) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
Returns a row containing dynamic-state information for each TCP listener.
NOTE
The availability group listener could listen to the same port as the listener of the instance of SQL Server. In this case, the
listeners are listed separately, the same as for a Service Broker listener.
Primary key.
Is not nullable.
1 = IPv4
0 = IPv6
0 = Transact-SQL
1 = Service Broker
2 = Database mirroring
Is not nullable.
COLUMN NAME DATA TYPE DESCRIPTION
TSQL
SERVICE_BROKER
DATABASE_MIRRORING
Is not nullable.
Is not nullable.
ONLINE
PENDING_RESTART
Is not nullable.
Security
Permissions
Requires VIEW SERVER STATE permission on the server.
See Also
Querying the SQL Server System Catalog FAQ
Always On Availability Groups Catalog Views (Transact-SQL )
Always On Availability Groups Dynamic Management Views and Functions (Transact-SQL )
Change Data Capture - sys.dm_cdc_errors
10/1/2018 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2008) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
Returns one row for each error encountered during the change data capture log scan session.
entry_time datetime The date and time the error was logged.
This value corresponds to the
timestamp in the SQL error log.
Permissions
Requires VIEW DATABASE STATE permission to query the sys.dm_cdc_errors dynamic management view. For
more information about permissions on dynamic management views, see Dynamic Management Views and
Functions (Transact-SQL ).
See Also
sys.dm_cdc_log_scan_sessions (Transact-SQL )
sys.dm_repl_traninfo (Transact-SQL )
Change Data Capture -
sys.dm_cdc_log_scan_sessions
10/1/2018 • 3 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2008) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
Returns one row for each log scan session in the current database. The last row returned represents the current
session. You can use this view to return status information about the current log scan session, or aggregated
information about all sessions since the instance of SQL Server was last started.
1: Reading configuration
2: First scan, building hash table
3: Second scan
4: Second scan
5: Second scan
6: Schema versioning
7: Last scan
8: Done
Remarks
The values in this dynamic management view are reset whenever the instance of SQL Server is started.
Permissions
Requires VIEW DATABASE STATE permission to query the sys.dm_cdc_log_scan_sessions dynamic
management view. For more information about permissions on dynamic management views, see Dynamic
Management Views and Functions (Transact-SQL ).
Examples
The following example returns information for the most current session.
USE AdventureWorks2012;
GO
SELECT session_id, start_time, end_time, duration, scan_phase
error_count, start_lsn, current_lsn, end_lsn, tran_count
last_commit_lsn, last_commit_time, log_record_count, schema_change_count
command_count, first_begin_cdc_lsn, last_commit_cdc_lsn,
last_commit_cdc_time, latency, empty_scan_count, failed_sessions_count
FROM sys.dm_cdc_log_scan_sessions
WHERE session_id = (SELECT MAX(b.session_id) FROM sys.dm_cdc_log_scan_sessions AS b);
GO
See Also
sys.dm_cdc_errors (Transact-SQL )
Change Tracking - sys.dm_tran_commit_table
10/1/2018 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2008) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
Displays one row for each transaction that is committed for a table that is tracked by SQL Server change tracking.
The sys.dm_tran_commit_table management view, which is provided for supportability purposes and exposes the
transaction-related information that change tracking stores in the sys.syscommittab system table. The
sys.syscommittab table provides an efficient persistent mapping from a database-specific transaction ID to the
transaction's commit log sequence number (LSN ) and commit timestamp. The data that is stored in the
sys.syscommittab table and exposed in this management view is subject to cleanup according to the retention
period specified when change tracking was configured.
NOTE
To call this from Azure SQL Data Warehouse or Parallel Data Warehouse, use the name
sys.dm_pdw_nodes_tran_commit_table.
See Also
Dynamic Management Views and Functions (Transact-SQL )
About Change Tracking (SQL Server)
Common Language Runtime Related Dynamic
Management Views (Transact-SQL)
10/1/2018 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2012) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
This section contains the following dynamic management views.
sys.dm_clr_appdomains sys.dm_clr_loaded_assemblies
sys.dm_clr_properties sys.dm_clr_tasks
See Also
Dynamic Management Views and Functions (Transact-SQL )
sys.dm_clr_appdomains (Transact-SQL)
11/14/2018 • 4 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2008) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
Returns a row for each application domain in the server. Application domain (AppDomain) is a construct in the
Microsoft .NET Framework common language runtime (CLR ) that is the unit of isolation for an application. You
can use this view to understand and troubleshoot CLR integration objects that are executing in Microsoft SQL
Server.
There are several types of CLR integration managed database objects. For general information about these
objects, see Building Database Objects with Common Language Runtime (CLR ) Integration. Whenever these
objects are executed, SQL Server creates an AppDomain under which it can load and execute the required code.
The isolation level for an AppDomain is one AppDomain per database per owner. That is, all CLR objects owned
by a user are always executed in the same AppDomain per-database (if a user registers CLR database objects in
different databases, the CLR database objects will run in different application domains). An AppDomain is not
destroyed after the code finishes execution. Instead, it is cached in memory for future executions. This improves
performance.
For more information, see Application Domains.
Remarks
There is a one-to-may relationship between dm_clr_appdomains.appdomain_address and
dm_clr_loaded_assemblies.appdomain_address.
The following tables list possible state values, their descriptions, and when they occur in the AppDomain
lifecycle. You can use this information to follow the lifecyle of an AppDomain and to watch for suspicious or
repetitive AppDomain instances unloading, without having to parse the Windows Event Log.
AppDomain Initialization
STATE DESCRIPTION
AppDomain Usage
STATE DESCRIPTION
AppDomain Cleanup
STATE DESCRIPTION
E_APPDOMAIN_UNLOADING SQL Server has requested that the CLR unload the
AppDomain, usually because the assembly that contains the
managed database objects has been altered or dropped.
E_APPDOMAIN_UNLOADED The CLR has unloaded the AppDomain. This is usually the
result of an escalation procedure due to ThreadAbort,
OutOfMemory, or an unhandled exception in user code.
Permissions
Requires VIEW SERVER STATE permission on the database.
Examples
The following example shows how to view the details of an AppDomain for a given assembly:
The following example shows how to view all assemblies in a given AppDomain:
See Also
sys.dm_clr_loaded_assemblies (Transact-SQL )
Common Language Runtime Related Dynamic Management Views (Transact-SQL )
sys.dm_clr_loaded_assemblies (Transact-SQL)
10/1/2018 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2008) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
Returns a row for each managed user assembly loaded into the server address space. Use this view to understand
and troubleshoot CLR integration managed database objects that are executing in Microsoft SQL Server.
Assemblies are managed code DLL files that are used to define and deploy managed database objects in SQL
Server. Whenever a user executes one of these managed database objects, SQL Server and the CLR load the
assembly (and its references) in which the managed database object is defined. The assembly remains loaded in
SQL Server to increase performance, so that the managed database objects contained in the assembly can be
called in the future with out having to reload the assembly. The assembly is not unloaded until SQL Server comes
under memory pressure. For more information about assemblies and CLR integration, see CLR Hosted
Environment. For more information about managed database objects, see Building Database Objects with
Common Language Runtime (CLR ) Integration.
Permissions
Requires VIEW SERVER STATE permission on the server.
Remarks
The dm_clr_loaded_assemblies.appdomain_address view has a many-to-one relationship with
dm_clr_appdomains.appdomain_address. The dm_clr_loaded_assemblies.assembly_id view has a one-to-
many relationship with sys.assemblies.assembly_id.
Examples
The following example shows how to view details of all assemblies in the current database that are currently
loaded.
The following example shows how to view details of the AppDomain in which a given assembly is loaded.
See Also
Common Language Runtime Related Dynamic Management Views (Transact-SQL )
sys.dm_clr_properties (Transact-SQL)
10/1/2018 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2008) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
Returns a row for each property related to SQL Server common language runtime (CLR ) integration, including the
version and state of the hosted CLR. The hosted CLR is initialized by running the CREATE ASSEMBLY, ALTER
ASSEMBLY, or DROP ASSEMBLY statements, or by executing any CLR routine, type, or trigger. The
sys.dm_clr_properties view does not specify whether execution of user CLR code has been enabled on the server.
Execution of user CLR code is enabled by using the sp_configure stored procedure with the clr enabled option set
to 1.
The sys.dm_clr_properties view contains the name and value columns. Each row in this view provides details
about a property of the hosted CLR. Use this view to gather information about the hosted CLR, such as the CLR
install directory, the CLR version, and the current state of the hosted CLR. This view can help you determine if the
CLR integration code is not working because of problems with the CLR installation on the server computer.
Properties
The directory property indicates the directory that the .NET Framework was installed to on the server. There
could be multiple installations of .NET Framework on the server computer and the value of this property identifies
which installation SQL Server is using.
The version property indicates the version of the .NET Framework and hosted CLR on the server.
The sys.dm_clr_properties dynamic managed view can return six different values for the state property, which
reflects the state of the SQL Server hosted CLR. They are:
Mscoree is not loaded.
Mscoree is loaded.
Locked CLR version with mscoree.
CLR is initialized.
CLR initialization permanently failed.
CLR is stopped.
The Mscoree is not loaded and Mscoree is loaded states show the progression of the hosted CLR
initialization on server startup, and are not likely to be seen.
The Locked CLR version with mscoree state may be seen where the hosted CLR is not being used and,
thus, it has not yet been initialized. The hosted CLR is initialized the first time a DDL statement (such as
CREATE ASSEMBLY (Transact-SQL )) or a managed database object is executed.
The CLR is initialized state indicates that the hosted CLR was successfully initialized. Note that this does
not indicate whether execution of user CLR code was enabled. If the execution of user CLR code is first
enabled and then disabled using the Transact-SQL sp_configure stored procedure, the state value will still
be CLR is initialized.
The CLR initialization permanently failed state indicates that hosted CLR initialization failed. Memory
pressure is a likely cause, or it could also be the result of a failure in the hosting handshake between SQL
Server and the CLR. Error message 6512 or 6513 will be thrown in such a case.
The CLR is stopped state is only seen when SQL Server is in the process of shutting down.
Remarks
The properties and values of this view might change in a future version of SQL Server due to enhancements of the
CLR integration functionality.
Permissions
On SQL Server, requires VIEW SERVER STATE permission.
On SQL Database, requires the VIEW DATABASE STATE permission in the database.
Examples
The following example retrieves information about the hosted CLR:
See Also
Dynamic Management Views and Functions (Transact-SQL )
Common Language Runtime Related Dynamic Management Views (Transact-SQL )
sys.dm_clr_tasks (Transact-SQL)
10/1/2018 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2008) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
Returns a row for all common language runtime (CLR ) tasks that are currently running. A Transact-SQL batch that
contains a reference to a CLR routine creates a separate task for execution of all the managed code in that batch.
Multiple statements in the batch that require managed code execution use the same CLR task. The CLR task is
responsible for maintaining objects and state pertaining to managed code execution, as well as the transitions
between the instance of SQL Server and the common language runtime.
Permissions
On SQL Server, requires VIEW SERVER STATE permission.
On SQL Database, requires the VIEW DATABASE STATE permission in the database.
See Also
Dynamic Management Views and Functions (Transact-SQL )
Common Language Runtime Related Dynamic Management Views (Transact-SQL )
Database Related Dynamic Management Views
(Transact-SQL)
10/1/2018 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2012) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
This section describes the following dynamic management objects in SQL Server and sometimes in SQL
Database.
sys.dm_db_file_space_usage sys.dm_db_fts_index_physical_stats
sys.dm_db_log_info sys.dm_db_log_space_usage
sys.dm_db_log_stats sys.dm_db_page_info
sys.dm_db_partition_stats sys.dm_db_persisted_sku_features
sys.dm_db_session_space_usage sys.dm_db_task_space_usage
sys.dm_db_uncontained_entities
See Also
Dynamic Management Views and Functions (Transact-SQL )
sys.dm_db_file_space_usage (Transact-SQL)
10/1/2018 • 4 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2008) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
Returns space usage information for each file in the database.
NOTE
To call this from Azure SQL Data Warehouse or Parallel Data Warehouse, use the name
sys.dm_pdw_nodes_db_file_space_usage.
Filegroup ID.
Remarks
Page counts are always at the extent level. Therefore, page count values will always be a multiple of eight. The
extents that contain Global Allocation Map (GAM ) and Shared Global Allocation Map (SGAM ) allocation pages
are allocated uniform extents. They are not included in the previously described page counts. For more
information about pages and extents, see Pages and Extents Architecture Guide.
The content of the current version store is in sys.dm_tran_version_store. Version store pages are tracked at the file
level instead of the session and task level, because they are global resources. A session may generate versions, but
the versions cannot be removed when the session ends. Version store cleanup must consider the longest running
transaction that needs access to the particular version. The longest running transaction related to version store
clean-up can be discovered by viewing the elapsed_time_seconds column in
sys.dm_tran_active_snapshot_database_transactions.
Frequent changes in the mixed_extent_page_count column may indicate heavy use of SGAM pages. When this
occurs, you may see many PAGELATCH_UP waits in which the wait resource is an SGAM page. For more
information, see sys.dm_os_waiting_tasks (Transact-SQL ), sys.dm_os_wait_stats (Transact-SQL ), and
sys.dm_os_latch_stats (Transact-SQL ).
User Objects
The following objects are included in the user object page counters:
User-defined tables and indexes
System tables and indexes
Global temporary tables and indexes
Local temporary tables and indexes
Table variables
Tables returned in the table-valued functions
Internal Objects
Internal objects are only in tempdb. The following objects are included in the internal object page counters:
Work tables for cursor or spool operations and temporary large object (LOB ) storage
Work files for operations such as a hash join
Sort runs
Relationship Cardinalities
FROM TO RELATIONSHIP
Permissions
On SQL Server, requires VIEW SERVER STATE permission.
On SQL Database, requires the VIEW DATABASE STATE permission in the database.
Examples
Determing the Amount of Free Space in tempdb
The following query returns the total number of free pages and total free space in megabytes (MB ) available in all
files in tempdb.
USE tempdb;
GO
SELECT SUM(unallocated_extent_page_count) AS [free pages],
(SUM(unallocated_extent_page_count)*1.0/128) AS [free space in MB]
FROM sys.dm_db_file_space_usage;
USE tempdb;
GO
SELECT SUM(user_object_reserved_page_count) AS [user object pages used],
(SUM(user_object_reserved_page_count)*1.0/128) AS [user object space in MB]
FROM sys.dm_db_file_space_usage;
See Also
Dynamic Management Views and Functions (Transact-SQL )
Database Related Dynamic Management Views (Transact-SQL )
sys.dm_db_task_space_usage (Transact-SQL )
sys.dm_db_session_space_usage (Transact-SQL )
sys.dm_db_fts_index_physical_stats (Transact-SQL)
10/1/2018 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2012) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
Returns a row for each full-text or semantic index in each table that has an associated full-text or semantic index.
General Remarks
For more information, see Manage and Monitor Semantic Search.
Metadata
For information about the status of semantic indexing, query the following dynamic management views:
sys.dm_fts_index_population (Transact-SQL )
sys.dm_fts_semantic_similarity_population (Transact-SQL )
Permissions
On SQL Server, requires VIEW SERVER STATE permission.
On SQL Database, requires the VIEW DATABASE STATE permission in the database.
Examples
The following example shows how to query for the logical size of each full-text or semantic index in every table
that has an associated full-text or semantic index:
APPLIES TO: SQL Server (starting with 2016 SP2) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
Returns virtual log file (VLF ) information of the transaction log. Note all transaction log files are combined in the
table output. Each row in the output represents a VLF in the transaction log and provides information relevant to
that VLF in the log.
Syntax
sys.dm_db_log_info ( database_id )
Arguments
database_id | NULL | DEFAULT
Is the ID of the database. database_id is int. Valid inputs are the ID number of a database, NULL, or DEFAULT. The
default is NULL. NULL and DEFAULT are equivalent values in the context of current database.
Specify NULL to return VLF information of the current database.
The built-in function DB_ID can be specified. When using DB_ID without specifying a database name, the
compatibility level of the current database must be 90 or greater.
Table Returned
COLUMN NAME DATA TYPE DESCRIPTION
Remarks
The sys.dm_db_log_info dynamic management function replaces the DBCC LOGINFO statement.
Permissions
Requires the VIEW DATABASE STATE permission in the database.
Examples
A. Determing databases in a SQL Server instance with high number of VLFs
The following query determines the databases with more than 100 VLFs in the log files, which can affect the
database startup, restore, and recovery time.
B. Determing the position of the last VLF in transaction log before shrinking the log file
The following query can be used to determine the position of the last active VLF before running shrinkfile on
transaction log to determine if transaction log can shrink.
USE AdventureWorks2016
GO
;WITH cte_vlf AS (
SELECT ROW_NUMBER() OVER(ORDER BY vlf_begin_offset) AS vlfid, DB_NAME(database_id) AS [Database Name],
vlf_sequence_number, vlf_active, vlf_begin_offset, vlf_size_mb
FROM sys.dm_db_log_info(DEFAULT)),
cte_vlf_cnt AS (SELECT [Database Name], COUNT(vlf_sequence_number) AS vlf_count,
(SELECT COUNT(vlf_sequence_number) FROM cte_vlf WHERE vlf_active = 0) AS vlf_count_inactive,
(SELECT COUNT(vlf_sequence_number) FROM cte_vlf WHERE vlf_active = 1) AS vlf_count_active,
(SELECT MIN(vlfid) FROM cte_vlf WHERE vlf_active = 1) AS ordinal_min_vlf_active,
(SELECT MIN(vlf_sequence_number) FROM cte_vlf WHERE vlf_active = 1) AS min_vlf_active,
(SELECT MAX(vlfid) FROM cte_vlf WHERE vlf_active = 1) AS ordinal_max_vlf_active,
(SELECT MAX(vlf_sequence_number) FROM cte_vlf WHERE vlf_active = 1) AS max_vlf_active
FROM cte_vlf
GROUP BY [Database Name])
SELECT [Database Name], vlf_count, min_vlf_active, ordinal_min_vlf_active, max_vlf_active,
ordinal_max_vlf_active,
((ordinal_min_vlf_active-1)*100.00/vlf_count) AS free_log_pct_before_active_log,
((ordinal_max_vlf_active-(ordinal_min_vlf_active-1))*100.00/vlf_count) AS active_log_pct,
((vlf_count-ordinal_max_vlf_active)*100.00/vlf_count) AS free_log_pct_after_active_log
FROM cte_vlf_cnt
GO
See Also
Dynamic Management Views and Functions (Transact-SQL )
Database Related Dynamic Management Views (Transact-SQL )
sys.dm_db_log_space_usage (Transact-SQL )
sys.dm_db_log_stats (Transact-SQL )
sys.dm_db_log_space_usage (Transact-SQL)
10/1/2018 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2012) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
Returns space usage information for the transaction log.
NOTE
All transaction log files are combined.
Permissions
On SQL Server, requires VIEW SERVER STATE permission.
On SQL Database, requires the VIEW DATABASE STATE permission in the database.
Examples
A. Determine the Amount of Free Log Space in tempdb
The following query returns the total free log space in megabytes (MB ) available in tempdb.
USE tempdb;
GO
See Also
Dynamic Management Views and Functions (Transact-SQL )
Database Related Dynamic Management Views (Transact-SQL )
sys.dm_db_file_space_usage
sys.dm_db_task_space_usage (Transact-SQL )
sys.dm_db_session_space_usage (Transact-SQL )
sys.dm_db_log_info (Transact-SQL )
sys.dm_db_log_stats (Transact-SQL )
sys.dm_db_log_stats (Transact-SQL)
10/1/2018 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2016 SP2) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
Returns summary level attributes and information on transaction log files of databases. Use this information for
monitoring and diagnostics of transaction log health.
Transact-SQL Syntax Conventions
Syntax
sys.dm_db_log_stats ( database_id )
Arguments
database_id | NULL | DEFAULT
Is the ID of the database. database_id is int . Valid inputs are the ID number of a database, NULL , or DEFAULT .
The default is NULL . NULL and DEFAULT are equivalent values in the context of current database.
The built-in function DB_ID can be specified. When using DB_ID without specifying a database name, the
compatibility level of the current database must be 90 or greater.
Tables Returned
COLUMN NAME DATA TYPE DESCRIPTION
Permissions
Requires the VIEW DATABASE STATE permission in the database.
Examples
A. Determining databases in a SQL Server instance with high number of VLFs
The following query returns the databases with more than 100 VLFs in the log files. Large numbers of VLFs can
affect the database startup, restore, and recovery time.
B. Determining databases in a SQL Server instance with transaction log backups older than 4 hours
The following query determines the last log backup times for the databases in the instance.
See Also
Dynamic Management Views and Functions (Transact-SQL )
Database Related Dynamic Management Views (Transact-SQL )
sys.dm_db_log_space_usage (Transact-SQL )
sys.dm_db_log_info (Transact-SQL )
sys.dm_db_objects_impacted_on_version_change
(Azure SQL Database)
10/1/2018 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server Azure SQL Database Azure SQL Data Warehouse Parallel Data
Warehouse
This database-scoped system view is designed to provide an early warning system to determine objects that will be
impacted by a major release upgrade in Azure SQL Database. You can use the view either before or after the
upgrade to get a full enumeration of impacted objects. You will need to query this view in each database to get a
full accounting across the entire server.
class int NOT NULL The class of the object which will be
impacted:
1 = constraint
OBJECT_OR_COLUMN
INDEX
Examples:
Permissions
Requires the VIEW DATABASE STATE permission.
Example
The following example shows a query on sys.dm_db_objects_impacted_on_version_change to find the objects
impacted by an upgrade to the next major server version
Remarks
How to Update Impacted Objects
The following ordered steps describe the corrective action to take after the upcoming June service release upgrade.
THIS TOPIC APPLIES TO: SQL Server (starting with 2019) Azure SQL Database Azure SQL Data
Warehouse Parallel Data Warehouse
Returns information about a page in a database. The function returns one row that contains the header information
from the page, including the object_id , index_id , and partition_id . This function replaces the need to use
DBCC PAGE in most cases.
Syntax
sys.dm_db_page_info ( DatabaseId, FileId, PageId, Mode )
Arguments
DatabaseId | NULL | DEFAULT
Is the ID of the database. DatabaseId is smallint. Valid input is the ID number of a database. The default is NULL,
however sending a NULL value for this parameter will result in an error.
FileId | NULL | DEFAULT
Is the ID of the file. FileId is int. Valid input is the ID number of a file in the database specified by DatabaseId. The
default is NULL, however sending a NULL value for this parameter will result in an error.
PageId | NULL | DEFAULT
Is the ID of the page. PageId is int. Valid input is the ID number of a page in the file specified by FileId. The default
is NULL, however sending a NULL value for this parameter will result in an error.
Mode | NULL | DEFAULT
Determines the level of detail in the output of the function. 'LIMITED' will return NULL values for all description
columns, 'DETAILED' will populate description columns. DEFAULT is 'LIMITED.'
Table Returned
COLUMN NAME DATA TYPE DESCRIPTION
Remarks
The dynamic management function returns page information like page_id , file_id ,
sys.dm_db_page_info
index_id , object_id etc. that are present in a page header. This information is useful for troubleshooting and
debugging various performance (lock and latch contention) and corruption issues.
sys.dm_db_page_info can be used in place of the DBCC PAGE statement in many cases, but it returns only the page
header information, not the body of the page. DBCC PAGE will still be needed for use cases where the entire
contents of the page are required.
Permissions
Requires the VIEW DATABASE STATE permission in the database.
Examples
A. Displaying all the properties of a page
The following query returns one row with all the page information for a given database_id , file_id , page_id
combination with default mode (‘LIMITED’)
SELECT *
FROM sys.dm_db_page_info (5, 1, 15, DEFAULT)
See Also
Dynamic Management Views and Functions (Transact-SQL )
Database Related Dynamic Management Views (Transact-SQL )
sys.dm_exec_requests (Transact-SQL )
sys.dm_db_partition_stats (Transact-SQL)
10/1/2018 • 4 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2008) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
Returns page and row -count information for every partition in the current database.
NOTE
To call this from Azure SQL Data Warehouse or Parallel Data Warehouse, use the name
sys.dm_pdw_nodes_db_partition_stats.
0 = Heap
1 = Clustered index.
Remarks
sys.dm_db_partition_stats displays information about the space used to store and manage in-row data LOB
data, and row -overflow data for all partitions in a database. One row is displayed per partition.
The counts on which the output is based are cached in memory or stored on disk in various system tables.
In-row data, LOB data, and row -overflow data represent the three allocation units that make up a partition. The
sys.allocation_units catalog view can be queried for metadata about each allocation unit in the database.
If a heap or index is not partitioned, it is made up of one partition (with partition number = 1); therefore, only one
row is returned for that heap or index. The sys.partitions catalog view can be queried for metadata about each
partition of all the tables and indexes in a database.
The total count for an individual table or an index can be obtained by adding the counts for all relevant partitions.
Permissions
Requires VIEW DATABASE STATE permission to query the sys.dm_db_partition_stats dynamic management
view. For more information about permissions on dynamic management views, see Dynamic Management Views
and Functions (Transact-SQL ).
Examples
A. Returning all counts for all partitions of all indexes and heaps in a database
The following example shows all counts for all partitions of all indexes and heaps in the AdventureWorks2012
database.
USE AdventureWorks2012;
GO
SELECT * FROM sys.dm_db_partition_stats;
GO
B. Returning all counts for all partitions of a table and its indexes
The following example shows all counts for all partitions of the HumanResources.Employee table and its indexes.
USE AdventureWorks2012;
GO
SELECT * FROM sys.dm_db_partition_stats
WHERE object_id = OBJECT_ID('HumanResources.Employee');
GO
C. Returning total used pages and total number of rows for a heap or clustered index
The following example returns total used pages and total number of rows for the heap or clustered index of the
HumanResources.Employee table. Because the Employee table is not partitioned by default, note the sum includes
only one partition.
USE AdventureWorks2012;
GO
SELECT SUM(used_page_count) AS total_number_of_used_pages,
SUM (row_count) AS total_number_of_rows
FROM sys.dm_db_partition_stats
WHERE object_id=OBJECT_ID('HumanResources.Employee') AND (index_id=0 or index_id=1);
GO
See Also
Dynamic Management Views and Functions (Transact-SQL )
Database Related Dynamic Management Views (Transact-SQL )
sys.dm_db_persisted_sku_features (Transact-SQL)
10/1/2018 • 3 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2008) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
Some features of the SQL Server Database Engine change the way that Database Engine stores information in the
database files. These features are restricted to specific editions of SQL Server. A database that contains these
features cannot be moved to an edition of SQL Server that does not support them. Use the
sys.dm_db_persisted_sku_features dynamic management view to list edition-specific features that are enabled in
the current database.
Applies to: SQL Server ( SQL Server 2008 through SQL Server 2017).
Permissions
Requires VIEW DATABASE STATE permission on the database.
Remarks
If no features that may be restricted by a specific edition are used by the database, the view returns no rows.
sys.dm_db_persisted_sku_features may list the following database-changing features as restricted to specific SQL
Server editions:
ChangeCapture: Indicates that a database has change data capture enabled. To remove change data
capture, use the sys.sp_cdc_disable_db stored procedure. For more information, see About Change Data
Capture (SQL Server).
ColumnStoreIndex: Indicates that at least one table has a columnstore index. To enable a database to be
moved to an edition of SQL Server that does not support this feature, use the DROP INDEX or ALTER
INDEX statement to remove the columnstore index. For more information, see Columnstore indexes.
Applies to: SQL Server ( SQL Server 2012 (11.x) through SQL Server 2017).
Compression: Indicates that at least one table or index uses data compression or the vardecimal storage
format. To enable a database to be moved to an edition of SQL Server that does not support this feature,
use the ALTER TABLE or ALTER INDEX statement to remove data compression. To remove vardecimal
storage format, use the sp_tableoption statement. For more information, see Data Compression.
MultipleFSContainers: Indicates that the database uses multiple FILESTREAM containers. The database
has a FILESTREAM filegroup with multiple containers (files). For more information, see FILESTREAM (SQL
Server).
InMemoryOLTP: Indicates that the database uses In-Memory OLTP. The database has a
MEMORY_OPTIMIZED_DATA filegroup. For more information, see In-Memory OLTP (In-Memory
Optimization).
Applies to: SQL Server ( SQL Server 2014 (12.x) through SQL Server 2017).
Partitioning. Indicates that the database contains partitioned tables, partitioned indexes, partition schemes,
or partition functions. To enable a database to be moved to an edition of SQL Server other than Enterprise
or Developer, it is insufficient to modify the table to be on a single partition. You must remove the
partitioned table. If the table contains data, use SWITCH PARTITION to convert each partition into a
nonpartitioned table. Then delete the partitioned table, the partition scheme, and the partition function.
TransparentDataEncryption. Indicates that a database is encrypted by using transparent data encryption.
To remove transparent data encryption, use the ALTER DATABASE statement. For more information, see
Transparent Data Encryption (TDE ).
NOTE
Starting with SQL Server 2016 (13.x) Service Pack 1, these features are available across multiple SQL Server Editions, and not
limited to Enterprise or Developer Editions only.
To determine whether a database uses any features that are restricted to specific editions, execute the following
statement in the database:
See Also
Dynamic Management Views and Functions (Transact-SQL )
Database Related Dynamic Management Views (Transact-SQL )
Editions and supported features of SQL Server 2016
Editions and supported features of SQL Server 2017
sys.dm_db_session_space_usage (Transact-SQL)
10/1/2018 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2008) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
Returns the number of pages allocated and deallocated by each session for the database.
NOTE
This view is applicable only to the tempdb database.
NOTE
To call this from Azure SQL Data Warehouse or Parallel Data Warehouse, use the name
sys.dm_pdw_nodes_db_session_space_usage.
Remarks
IAM pages are not included in any of the allocation or deallocation counts reported by this view.
Page counters are initialized to zero (0) at the start of a session. The counters track the total number of pages that
have been allocated or deallocated for tasks that are already completed in the session. The counters are updated
only when a task ends; they do not reflect running tasks.
A session can have multiple requests active at the same time. A request can start multiple threads, tasks, if it is a
parallel query.
For more information about the sessions, requests, and tasks, see sys.dm_exec_sessions (Transact-SQL ),
sys.dm_exec_requests (Transact-SQL ), and sys.dm_os_tasks (Transact-SQL ).
User Objects
The following objects are included in the user object page counters:
User-defined tables and indexes
System tables and indexes
Global temporary tables and indexes
Local temporary tables and indexes
Table variables
Tables returned in the table-valued functions
Internal Objects
Internal objects are only in tempdb. The following objects are included in the internal object page counters:
Work tables for cursor or spool operations and temporary large object (LOB ) storage
Work files for operations such as a hash join
Sort runs
Physical Joins
Relationship Cardinalities
FROM TO RELATIONSHIP
See Also
Dynamic Management Views and Functions (Transact-SQL )
Database Related Dynamic Management Views (Transact-SQL )
sys.dm_exec_sessions (Transact-SQL )
sys.dm_exec_requests (Transact-SQL )
sys.dm_os_tasks (Transact-SQL )
sys.dm_db_task_space_usage (Transact-SQL )
sys.dm_db_file_space_usage (Transact-SQL )
sys.dm_db_task_space_usage (Transact-SQL)
10/1/2018 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2008) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
Returns page allocation and deallocation activity by task for the database.
NOTE
This view is applicable only to the tempdb database.
NOTE
To call this from Azure SQL Data Warehouse or Parallel Data Warehouse, use the name
sys.dm_pdw_nodes_db_task_space_usage.
Permissions
On SQL Server, requires VIEW SERVER STATE permission.
On SQL Database, requires the VIEW DATABASE STATE permission in the database.
Remarks
IAM pages are not included in any of the page counts reported by this view.
Page counters are initialized to zero (0) at the start of a request. These values are aggregated at the session level
when the request is completed. For more information, see sys.dm_db_session_space_usage (Transact-SQL ).
Work table caching, temporary table caching, and deferred drop operations affect the number of pages allocated
and deallocated in a specified task.
User Objects
The following objects are included in the user object page counters:
User-defined tables and indexes
System tables and indexes
Global temporary tables and indexes
Local temporary tables and indexes
Table variables
Tables returned in the table-valued functions
Internal Objects
Internal objects are only in tempdb. The following objects are included in the internal object page counters:
Work tables for cursor or spool operations and temporary large object (LOB ) storage
Work files for operations such as a hash join
Sort runs
Physical Joins
Relationship Cardinalities
FROM TO RELATIONSHIP
See Also
Dynamic Management Views and Functions (Transact-SQL )
Database Related Dynamic Management Views (Transact-SQL )
sys.dm_exec_sessions (Transact-SQL )
sys.dm_exec_requests (Transact-SQL )
sys.dm_os_tasks (Transact-SQL )
sys.dm_db_session_space_usage (Transact-SQL )
sys.dm_db_file_space_usage (Transact-SQL )
sys.dm_db_uncontained_entities (Transact-SQL)
10/1/2018 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2012) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
Shows any uncontained objects used in the database. Uncontained objects are objects that cross the database
boundary in a contained database. This view is accessible from both a contained database and a non-contained
database. If sys.dm_db_uncontained_entities is empty, your database does not use any uncontained entities.
If a module crosses the database boundary more than once, only the first discovered crossing is reported.
4 = Database Principal
5 = Assembly
6 = Type
19 = Route
30 = Audit Specification
OBJECT_OR_COLUMN
DATABASE_PRINCIPAL
ASSEMBLY
TYPE
INDEX
DATABASE_DDL_TRIGGER
ROUTE
AUDIT_SPECIFICATION
major_id int ID of the entity.
If class = 4, then
sys.database_principals.principal_id.
If class = 5, then
sys.assemblies.assembly_id.
Remarks
sys.dm_db_uncontained_entities shows those entities which can potentially cross the database boundary. It will
return any user entities that have the potential to use objects outside of the database.
The following feature types are reported.
Unknown containment behavior (dynamic SQL or deferred name resolution)
DBCC command
System stored procedure
System scalar function
System table valued function
System built-in function
Security
Permissions
sys.dm_db_uncontained_entities only returns objects for which the user has some type of permission. To fully
evaluate the containment of the database this function should be used by a high privileged user such as a member
of the sysadmin fixed server role or the db_owner role.
Examples
The following example creates a procedure named P1, and then queries sys.dm_db_uncontained_entities . The
query reports that P1 uses sys.endpoints which is outside of the database.
USE Test;
GO
CREATE PROC P1
AS
SELECT * FROM sys.endpoints ;
GO
SELECT SO.name, UE.* FROM sys.dm_db_uncontained_entities AS UE
LEFT JOIN sys.objects AS SO
ON UE.major_id = SO.object_id;
See Also
Contained Databases
sys.dm_db_wait_stats (Azure SQL Database)
10/1/2018 • 36 minutes to read • Edit Online
APPLIES TO: SQL Server Azure SQL Database Azure SQL Data Warehouse Parallel Data
Warehouse
Returns information about all the waits encountered by threads that executed during operation. You can use this
aggregated view to diagnose performance issues with Azure SQL Database and also with specific queries and
batches.
Specific types of wait times during query execution can indicate bottlenecks or stall points within the query.
Similarly, high wait times, or wait counts server wide can indicate bottlenecks or hot spots in interaction query
interactions within the server instance. For example, lock waits indicate data contention by queries; page IO latch
waits indicate slow IO response times; page latch update waits indicate incorrect file layout.
Remarks
This dynamic management view displays data only for the current database.
This dynamic management view shows the time for waits that have completed. It does not show current
waits.
Counters are reset to zero any time the database is moved or taken offline.
A SQL Server worker thread is not considered to be waiting if any of the following is true:
A resource becomes available.
A queue is nonempty.
An external process finishes.
These statistics are not persisted across SQL Database failover events, and all data are cumulative since the
last time the statistics were reset.
Permissions
Requires VIEW DATABASE STATE permission on the server.
Types of Waits
Resource waits
Resource waits occur when a worker requests access to a resource that is not available because the resource is
being used by some other worker or is not yet available. Examples of resource waits are locks, latches, network and
disk I/O waits. Lock and latch waits are waits on synchronization objects.
Queue waits
Queue waits occur when a worker is idle, waiting for work to be assigned. Queue waits are most typically seen
with system background tasks such as the deadlock monitor and deleted record cleanup tasks. These tasks will
wait for work requests to be placed into a work queue. Queue waits may also periodically become active even if no
new packets have been put on the queue.
External waits
External waits occur when a SQL Server worker is waiting for an external event, such as an extended stored
procedure call or a linked server query, to finish. When you diagnose blocking issues, remember that external
waits do not always imply that the worker is idle, because the worker may actively be running some external code.
Although the thread is no longer waiting, the thread does not have to start running immediately. This is because
such a thread is first put on the queue of runnable workers and must wait for a quantum to run on the scheduler.
In SQL Server the wait-time counters are bigint values and therefore are not as prone to counter rollover as the
equivalent counters in earlier versions of SQL Server.
The following table lists the wait types encountered by tasks.
ASYNC_NETWORK_IO Occurs on network writes when the task is blocked behind the
network. Verify that the client is processing data from the
server.
BACKUP_OPERATOR Occurs when a task is waiting for a tape mount. To view the
tape status, query sys.dm_io_backup_tapes. If a mount
operation is not pending, this wait type may indicate a
hardware problem with the tape drive.
BACKUPBUFFER Occurs when a backup task is waiting for data, or is waiting for
a buffer in which to store data. This type is not typical, except
when a task is waiting for a tape mount.
BACKUPIO Occurs when a backup task is waiting for data, or is waiting for
a buffer in which to store data. This type is not typical, except
when a task is waiting for a tape mount.
BACKUPTHREAD Occurs when a task is waiting for a backup task to finish. Wait
times may be long, from several minutes to several hours. If
the task that is being waited on is in an I/O process, this type
does not indicate a problem.
BROKER_MASTERSTART Occurs when a task is waiting for the primary event handler of
the Service Broker to start. This should occur very briefly.
BROKER_TASK_STOP Occurs when the Service Broker queue task handler tries to
shut down the task. The state check is serialized and must be
in a running state beforehand.
BROKER_TO_FLUSH Occurs when the Service Broker lazy flusher flushes the in-
memory transmission objects to a work table.
CHECKPOINT_QUEUE Occurs while the checkpoint task is waiting for the next
checkpoint request.
DEADLOCK_TASK_SEARCH Large waiting time on this resource indicates that the server is
executing queries on top of sys.dm_os_waiting_tasks, and
these queries are blocking deadlock monitor from running
deadlock search. This wait type is used by deadlock monitor
only. Queries on top of sys.dm_os_waiting_tasks use
DEADLOCK_ENUM_MUTEX.
DISPATCHER_QUEUE_SEMAPHORE Occurs when a thread from the dispatcher pool is waiting for
more work to process. The wait time for this wait type is
expected to increase when the dispatcher is idle.
DLL_LOADING_MUTEX Occurs once while waiting for the XML parser DLL to load.
ENABLE_VERSIONING Occurs when SQL Server waits for all update transactions in
this database to finish before declaring the database ready to
transition to snapshot isolation allowed state. This state is
used when SQL Server enables snapshot isolation by using the
ALTER DATABASE statement.
IMPPROV_IOWAIT Occurs when SQL Server waits for a bulkload I/O to finish.
IO_COMPLETION Occurs while waiting for I/O operations to complete. This wait
type generally represents non-data page I/Os. Data page I/O
completion waits appear as PAGEIOLATCH_* waits.
IO_QUEUE_LIMIT Occurs when the asynchronous IO queue for the Azure SQL
Database has too many IOs pending. Tasks trying to issue
another IO are blocked on this wait type until the number of
pending IOs drop below the threshold. The threshold is
proportional to the DTUs assigned to the database.
KSOURCE_WAKEUP Used by the service control task while waiting for requests
from the Service Control Manager. Long waits are expected
and do not indicate a problem.
LATCH_DT Occurs when waiting for a DT (destroy) latch. This does not
include buffer latches or transaction mark latches. A listing of
LATCH_* waits is available in sys.dm_os_latch_stats. Note that
sys.dm_os_latch_stats groups LATCH_NL, LATCH_SH,
LATCH_UP, LATCH_EX, and LATCH_DT waits together.
WAIT TYPE DESCRIPTION
LATCH_EX Occurs when waiting for an EX (exclusive) latch. This does not
include buffer latches or transaction mark latches. A listing of
LATCH_* waits is available in sys.dm_os_latch_stats. Note that
sys.dm_os_latch_stats groups LATCH_NL, LATCH_SH,
LATCH_UP, LATCH_EX, and LATCH_DT waits together.
LATCH_KP Occurs when waiting for a KP (keep) latch. This does not
include buffer latches or transaction mark latches. A listing of
LATCH_* waits is available in sys.dm_os_latch_stats. Note that
sys.dm_os_latch_stats groups LATCH_NL, LATCH_SH,
LATCH_UP, LATCH_EX, and LATCH_DT waits together.
LATCH_SH Occurs when waiting for an SH (share) latch. This does not
include buffer latches or transaction mark latches. A listing of
LATCH_* waits is available in sys.dm_os_latch_stats. Note that
sys.dm_os_latch_stats groups LATCH_NL, LATCH_SH,
LATCH_UP, LATCH_EX, and LATCH_DT waits together.
LATCH_UP Occurs when waiting for an UP (update) latch. This does not
include buffer latches or transaction mark latches. A listing of
LATCH_* waits is available in sys.dm_os_latch_stats. Note that
sys.dm_os_latch_stats groups LATCH_NL, LATCH_SH,
LATCH_UP, LATCH_EX, and LATCH_DT waits together.
LOGBUFFER Occurs when a task is waiting for space in the log buffer to
store a log record. Consistently high values may indicate that
the log devices cannot keep up with the amount of log being
generated by the server.
LOGMGR Occurs when a task is waiting for any outstanding log I/Os to
finish before shutting down the log while closing the database.
LOGMGR_QUEUE Occurs while the log writer task waits for work requests.
MSSEARCH Occurs during Full-Text Search calls. This wait ends when the
full-text operation completes. It does not indicate contention,
but rather the duration of full-text operations.
OLEDB Occurs when SQL Server calls the SQL Server Native Client
OLE DB Provider. This wait type is not used for
synchronization. Instead, it indicates the duration of calls to
the OLE DB provider.
ONDEMAND_TASK_QUEUE Occurs while a background task waits for high priority system
task requests. Long wait times indicate that there have been
no high priority requests to process, and should not cause
concern.
QUERY_EXECUTION_INDEX_SORT_EVENT_OPEN Occurs in certain cases when offline create index build is run in
parallel, and the different worker threads that are sorting
synchronize access to the sort files.
REQUEST_FOR_DEADLOCK_SEARCH Occurs while the deadlock monitor waits to start the next
deadlock search. This wait is expected between deadlock
detections, and lengthy total waiting time on this resource
does not indicate a problem.
RESOURCE_SEMAPHORE_MUTEX Occurs while a query waits for its request for a thread
reservation to be fulfilled. It also occurs when synchronizing
query compile and memory grant requests.
SE_REPL_SLOW_SECONDARY_THROTTLE Occurs when the thread is waiting for one of the database
secondary replicas.
SECURITY_MUTEX Occurs when there is a wait for mutexes that control access to
the global list of Extensible Key Management (EKM)
cryptographic providers and the session-scoped list of EKM
sessions.
SLEEP_DBSTARTUP Occurs during database startup while waiting for all databases
to recover.
SLEEP_DCOMSTARTUP Occurs once at most during SQL Server instance startup while
waiting for DCOM initialization to complete.
SLEEP_MSDBSTARTUP Occurs when SQL Trace waits for the msdb database to
complete startup.
SLEEP_SYSTEMTASK Occurs during the start of a background task while waiting for
tempdb to complete startup.
SLEEP_TASK Occurs when a task sleeps while waiting for a generic event to
occur.
SNI_TASK_COMPLETION Occurs when there is a wait for all tasks to finish during a
NUMA node state change.
SOS_SCHEDULER_YIELD Occurs when a task voluntarily yields the scheduler for other
tasks to execute. During this wait the task is waiting for its
quantum to be renewed.
SOSHOST_SLEEP Occurs when a hosted task sleeps while waiting for a generic
event to occur. Hosted tasks are used by hosted components
such as CLR.
SQLCLR_ASSEMBLY Occurs while waiting for access to the loaded assembly list in
the appdomain.
SQLTRACE_WAIT_ENTRIES Occurs while a SQL Trace event queue waits for packets to
arrive on the queue.
THREADPOOL Occurs when a task is waiting for a worker to run on. This can
indicate that the maximum worker setting is too low, or that
batch executions are taking unusually long, thus reducing the
number of workers available to satisfy other batches.
TRACEWRITE Occurs when the SQL Trace rowset trace provider waits for
either a free buffer or a buffer with events to process.
APPLIES TO: SQL Server Azure SQL Database Azure SQL Data Warehouse Parallel Data
Warehouse
Returns information about operations performed on databases in a Azure SQL Database server.
0 = Pending
1 = In progress
2 = Completed
3 = Failed
4 = Cancelled
Permissions
This view is only available in the master database to the server-level principal login.
Remarks
To use this view, you must be connected to the master database. Use the sys.dm_operation_status view in the
master database of the SQL Database server to track the status of the following operations performed on a SQL
Database:
Create database
Copy database. Database Copy creates a record in this view on both the source and target servers.
Alter database
Change the performance level of a service tier
Change the service tier of a database, such as changing from Basic to Standard.
Setting up a Geo-Replication relationship
Terminating a Geo-Replication relationship
Restore database
Delete database
Example
Show most recent geo-replication operations associated with database ‘mydb’.
See Also
Geo-Replication Dynamic Management Views and Functions (Azure SQL Database)
sys.dm_geo_replication_link_status (Azure SQL Database)
sys.geo_replication_links (Azure SQL Database)
ALTER DATABASE (Azure SQL Database)
sys.dm_database_copies (Azure SQL Database)
10/1/2018 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server Azure SQL Database Azure SQL Data Warehouse Parallel Data
Warehouse
Returns information about the database copy.
To return information about geo-replication links, use the sys.geo_replication_links or
sys.dm_geo_replication_link_status views (available in SQL Database V12).
PENDING
SEEDING
1 = Copy database
Permissions
This view is only available in the master database to the server-level principal login.
Remarks
You can use the sys.dm_database_copies view in the master database of the source or target SQL Database
server. When the database copy completes successfully and the new database becomes ONLINE, the row in the
sys.dm_database_copies view is removed automatically.
sys.dm_db_resource_stats (Azure SQL Database)
10/1/2018 • 3 minutes to read • Edit Online
APPLIES TO: SQL Server Azure SQL Database Azure SQL Data Warehouse Parallel Data
Warehouse
Returns CPU, I/O, and memory consumption for an Azure SQL Database database. One row exists for every 15
seconds, even if there is no activity in the database. Historical data is maintained for one hour.
TIP
For more context about these limits and service tiers, see the topics Service Tiers and Service tier capabilities and limits.
Permissions
This view requires VIEW DATABASE STATE permission.
Remarks
The data returned by sys.dm_db_resource_stats is expressed as a percentage of the maximum allowed limits for
the service tier/performance level that you are running.
If the database was failed over to another server within the last 60 minutes, the view will only return data for the
time it has been the primary database since that failover.
For a less granular view of this data, use sys.resource_stats catalog view in the master database. This view
captures data every 5 minutes and maintains historical data for 14 days. For more information, see
sys.resource_stats (Azure SQL Database).
When a database is a member of an elastic pool, resource statistics presented as percent values, are expressed as
the percent of the max limit for the databases as set in the elastic pool configuration.
Example
The following example returns resource utilization data ordered by the most recent time for the currently
connected database.
The following example identifies the average DTU consumption in terms of a percentage of the maximum allowed
DTU limit in the performance level for the user database over the past hour. Consider increasing the performance
level as these percentages near 100% on a consistent basis.
SELECT end_time,
(SELECT Max(v)
FROM (VALUES (avg_cpu_percent), (avg_data_io_percent), (avg_log_write_percent)) AS
value(v)) AS [avg_DTU_percent]
FROM sys.dm_db_resource_stats;
The following example returns the average and maximum values for CPU percent, data and log I/O, and memory
consumption over the last hour.
SELECT
AVG(avg_cpu_percent) AS 'Average CPU Utilization In Percent',
MAX(avg_cpu_percent) AS 'Maximum CPU Utilization In Percent',
AVG(avg_data_io_percent) AS 'Average Data IO In Percent',
MAX(avg_data_io_percent) AS 'Maximum Data IO In Percent',
AVG(avg_log_write_percent) AS 'Average Log Write I/O Throughput Utilization In Percent',
MAX(avg_log_write_percent) AS 'Maximum Log Write I/O Throughput Utilization In Percent',
AVG(avg_memory_usage_percent) AS 'Average Memory Usage In Percent',
MAX(avg_memory_usage_percent) AS 'Maximum Memory Usage In Percent'
FROM sys.dm_db_resource_stats;
See Also
sys.resource_stats (Azure SQL Database)
Service Tiers
Service tier capabilities and limits
Database Mirroring -
sys.dm_db_mirroring_auto_page_repair
10/1/2018 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2008) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
Returns a row for every automatic page-repair attempt on any mirrored database on the server instance. This view
contains rows for the latest automatic page-repair attempts on a given mirrored database, with a maximum of 100
rows per database. As soon as a database reaches the maximum, the row for its next automatic page-repair attempt
replaces one of the existing entries. The following table defines the meaning of the various columns.
2 = Bad checksum
3 = Torn page
Security
Permissions
Requires VIEW SERVER STATE permission on the server.
See Also
Automatic Page Repair (Availability Groups: Database Mirroring)
Dynamic Management Views and Functions (Transact-SQL )
suspect_pages (Transact-SQL )
Manage the suspect_pages Table (SQL Server)
Database Mirroring -
sys.dm_db_mirroring_connections
10/1/2018 • 4 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2008) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
Returns a row for each connection established for database mirroring.
1 = NEW
2 = CONNECTING
3 = CONNECTED
4 = LOGGED_IN
5 = CLOSED
NEW
CONNECTING
CONNECTED
LOGGED_IN
CLOSED
0 = INITIAL
2 = ONE ISC
3 = ONE ASC
4 = TWO ISC
5 = TWO ASC
8 = WAIT REJECT
10 = WAIT VALIDATION
11 = WAIT ARBITRATION
12 = ONLINE
13 = ERROR
COLUMN NAME DATA TYPE DESCRIPTION
Connection is in error.
Value:0
Description: None
Value:1
Description: RC4
Value:2
Description: AES
Value:3
Value:4
Value:5
Value:6
Value:7
Value:8
Description: None
Description: RC4
Description: AES
1 = True
1 = True
Permissions
Requires VIEW SERVER STATE permission on the server.
Physical Joins
Relationship Cardinalities
FROM TO RELATIONSHIP
See Also
Dynamic Management Views and Functions (Transact-SQL )
Monitoring Database Mirroring (SQL Server)
Execution Related Dynamic Management Views and
Functions (Transact-SQL)
11/14/2018 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2008) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
This section contains the following dynamic management objects:
sys.dm_exec_background_job_queue sys.dm_exec_background_job_queue_stats
sys.dm_exec_cached_plan_dependent_objects sys.dm_exec_cached_plans
sys.dm_exec_compute_node_errors sys.dm_exec_compute_node_status
sys.dm_exec_compute_nodes sys.dm_exec_connections
sys.dm_exec_cursors sys.dm_exec_describe_first_result_set
sys.dm_exec_describe_first_result_set_for_object sys.dm_exec_distributed_request_steps
sys.dm_exec_distributed_requests sys.dm_exec_distributed_sql_requests
sys.dm_exec_dms_services sys.dm_exec_dms_workers
sys.dm_exec_external_operations sys.dm_exec_external_work
sys.dm_exec_function_stats sys.dm_exec_input_buffer
sys.dm_exec_plan_attributes sys.dm_exec_procedure_stats
sys.dm_exec_query_memory_grants sys.dm_exec_query_optimizer_info
sys.dm_exec_query_optimizer_memory_gateways sys.dm_exec_query_plan
sys.dm_exec_query_parallel_workers sys.dm_exec_query_profiles
sys.dm_exec_query_resource_semaphores sys.dm_exec_query_statistics_xml
sys.dm_exec_query_stats sys.dm_exec_requests
sys.dm_exec_session_wait_stats sys.dm_exec_sessions
sys.dm_exec_sql_text sys.dm_exec_text_query_plan
sys.dm_exec_trigger_stats sys.dm_exec_valid_use_hints
sys.dm_exec_xml_handles sys.dm_external_script_execution_stats
sys.dm_external_script_requests
NOTE
The sys.dm_exec_query_transformation_stats dynamic management view is identified for informational purposes only.
Not supported. Future compatibility is not guaranteed.
See Also
Dynamic Management Views and Functions (Transact-SQL )
System Views (Transact-SQL )
sys.dm_exec_background_job_queue (Transact-SQL)
10/1/2018 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2008) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
Returns a row for each query processor job that is scheduled for asynchronous (background) execution.
NOTE!! To call this from Azure SQL Data Warehouse or Parallel Data Warehouse, use the name
sys.dm_pdw_nodes_exec_background_job_queue.
1 = Started
0 = Still waiting
COLUMN NAME DATA TYPE DESCRIPTION
Permissions
On SQL Server, requires VIEW SERVER STATE permission.
On SQL Database, requires the VIEW DATABASE STATE permission in the database.
Remarks
This view returns information only for asynchronous update statistics jobs. For more information about
asynchronous update statistics, see Statistics.
The values of object_id1 through object_id4 depend on the type of the job request. The following table
summarizes the meaning of these columns for the different job types.
Examples
The following example returns the number of active asynchronous jobs in the background queue for each database
in the instance of SQL Server.
See Also
Dynamic Management Views and Functions (Transact-SQL )
Execution Related Dynamic Management Views and Functions (Transact-SQL )
Statistics
KILL STATS JOB (Transact-SQL )
sys.dm_exec_background_job_queue_stats (Transact-
SQL)
10/1/2018 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2008) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
Returns a row that provides aggregate statistics for each query processor job submitted for asynchronous
(background) execution.
NOTE
To call this from Azure SQL Data Warehouse or Parallel Data Warehouse, use the name
sys.dm_pdw_nodes_exec_background_job_queue_stats.
Remarks
This view returns information only for asynchronous update statistics jobs. For more information about
asynchronous update statistics, see Statistics.
Permissions
On SQL Server, requires VIEW SERVER STATE permission.
On SQL Database, requires the VIEW DATABASE STATE permission in the database.
Examples
A. Determining the percentage of failed background jobs
The following example returns the percentage of failed background jobs for all executed queries.
SELECT
CASE ended_count WHEN 0
THEN 'No jobs ended'
ELSE CAST((failed_lock_count + failed_giveup_count + failed_other_count) / CAST(ended_count AS
float) * 100 AS varchar(20))
END AS [Percent Failed]
FROM sys.dm_exec_background_job_queue_stats;
GO
SELECT
CASE enqueued_count WHEN 0
THEN 'No jobs posted'
ELSE CAST((enqueue_failed_full_count + enqueue_failed_duplicate_count) / CAST(enqueued_count
AS float) * 100 AS varchar(20))
END AS [Percent Enqueue Failed]
FROM sys.dm_exec_background_job_queue_stats;
GO
See Also
Dynamic Management Views and Functions (Transact-SQL )
Execution Related Dynamic Management Views and Functions (Transact-SQL )
sys.dm_exec_cached_plan_dependent_objects
(Transact-SQL)
10/1/2018 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2008) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
Returns a row for each Transact-SQL execution plan, common language runtime (CLR ) execution plan, and cursor
associated with a plan.
Syntax
dm_exec_cached_plan_dependent_objects(plan_handle)
Arguments
plan_handle
Uniquely identifies a query execution plan for a batch that has executed and its plan resides in the plan cache.
plan_handle is varbinary(64). The plan_handle can be obtained from the following dynamic management objects:
sys.dm_exec_cached_plans (Transact-SQL )
sys.dm_exec_query_stats (Transact-SQL )
sys.dm_exec_requests (Transact-SQL )
Table Returned
COLUMN NAME DATA TYPE DESCRIPTION
Executable plan
Cursor
Permissions
Requires VIEW SERVER STATE permission on the server.
Physical Joins
Relationship Cardinalities
FROM TO ON RELATIONSHIP
See Also
Execution Related Dynamic Management Views and Functions (Transact-SQL )
Dynamic Management Views and Functions (Transact-SQL )
sys.syscacheobjects (Transact-SQL )
sys.dm_exec_cached_plans (Transact-SQL)
10/1/2018 • 3 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2008) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
Returns a row for each query plan that is cached by SQL Server for faster query execution. You can use this
dynamic management view to find cached query plans, cached query text, the amount of memory taken by
cached plans, and the reuse count of the cached plans.
In Azure SQL Database, dynamic management views cannot expose information that would impact database
containment or expose information about other databases the user has access to. To avoid exposing this
information, every row that contains data that doesn’t belong to the connected tenant is filtered out. In addition,
the values in the columns memory_object_address and pool_id are filtered; the column value is set to NULL.
NOTE
To call this from Azure SQL Data Warehouse or Parallel Data Warehouse, use the name
sys.dm_pdw_nodes_exec_cached_plans.
Compiled Plan
Parse Tree
Extended Proc
sys.dm_exec_sql_text
sys.dm_exec_query_plan
sys.dm_exec_plan_attributes
Permissions
On SQL Server, requires VIEW SERVER STATE permission.
On SQL Database, requires the VIEW DATABASE STATE permission in the database.
Examples
A. Returning the batch text of cached entries that are reused
The following example returns the SQL text of all cached entries that have been used more than once.
C. Returning the SET options with which the plan was compiled
The following example returns the SET options with which the plan was compiled. The sql_handle for the plan is
also returned. The PIVOT operator is used to output the set_options and sql_handle attributes as columns
rather than as rows. For more information about the value returned in set_options , see
sys.dm_exec_plan_attributes (Transact-SQL ).
See Also
Dynamic Management Views and Functions (Transact-SQL )
Execution Related Dynamic Management Views and Functions (Transact-SQL )
sys.dm_exec_query_plan (Transact-SQL )
sys.dm_exec_plan_attributes (Transact-SQL )
sys.dm_exec_sql_text (Transact-SQL )
sys.dm_os_memory_objects (Transact-SQL )
sys.dm_os_memory_cache_entries (Transact-SQL )
FROM (Transact-SQL )
sys.dm_exec_compute_node_errors (Transact-SQL)
11/14/2018 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2016) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
Returns errors that occur on PolyBase compute nodes.
See Also
PolyBase troubleshooting with dynamic management views
Dynamic Management Views and Functions (Transact-SQL )
Database Related Dynamic Management Views (Transact-SQL )
sys.dm_exec_compute_node_status (Transact-SQL)
11/14/2018 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2016) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
Holds additional information about the performance and status of all PolyBase nodes. Lists one row per node.
process_id int
total_elapsed_time bigint Total time elapsed since Total time elapsed since
system start or restart. system start or restart. If
total_elapsed_time exceeds
the maximum value for an
integer (24.8 days in
milliseconds), it will cause
materialization failure due to
overflow.The maximum value
in milliseconds is equivalent
to 24.8 days.
See Also
PolyBase troubleshooting with dynamic management views
Dynamic Management Views and Functions (Transact-SQL )
Database Related Dynamic Management Views (Transact-SQL )
sys.dm_exec_compute_nodes (Transact-SQL)
11/14/2018 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2016) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
Holds information about nodes used with PolyBase data management. It lists one row per node.
Use this DMV to see the list of all nodes in the scale-out cluster with their role, name and IP address.
See Also
PolyBase troubleshooting with dynamic management views
Dynamic Management Views and Functions (Transact-SQL )
Database Related Dynamic Management Views (Transact-SQL )
sys.dm_exec_connections (Transact-SQL)
10/1/2018 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2008) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
Returns information about the connections established to this instance of SQL Server and the details of each
connection. Returns server wide connection information for SQL Server. Returns current database connection
information for SQL Database.
NOTE
To call this from Azure SQL Data Warehouse or Parallel Data Warehouse, use sys.dm_pdw_exec_connections (Transact-SQL).
Permissions
On SQL Server, requires VIEW SERVER STATE permission.
On SQL Database, requires the VIEW DATABASE STATE permission in the database.
Physical Joins
Relationship Cardinalities
Examples
Typical query to gather information about a queries own connection.
SELECT
c.session_id, c.net_transport, c.encrypt_option,
c.auth_scheme, s.host_name, s.program_name,
s.client_interface_name, s.login_name, s.nt_domain,
s.nt_user_name, s.original_login_name, c.connect_time,
s.login_time
FROM sys.dm_exec_connections AS c
JOIN sys.dm_exec_sessions AS s
ON c.session_id = s.session_id
WHERE c.session_id = @@SPID;
See Also
Execution Related Dynamic Management Views and Functions (Transact-SQL )
sys.dm_exec_cursors (Transact-SQL)
10/1/2018 • 3 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2008) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
Returns information about the cursors that are open in various databases.
Syntax
dm_exec_cursors (session_id | 0 )
Arguments
session_id | 0
ID of the session. If session_id is specified, this function returns information about cursors in the specified session.
If 0 is specified, the function returns information about all cursors for all sessions.
Table Returned
COLUMN NAME DATA TYPE DESCRIPTION
Permissions
Requires VIEW SERVER STATE permission on the server.
Remarks
The following table provides information about the cursor declaration interface and includes the possible values
for the properties column.
PROPERTY DESCRIPTION
API Cursor was declared by using one of the data access APIs
(ODBC, OLEDB).
The following table provides information about the cursor type and includes the possible values for the properties
column.
TYPE DESCRIPTION
The following table provides information about cursor concurrency and includes the possible values for the
properties column.
CONCURRENCY DESCRIPTION
The following table provides information about cursor scope and includes the possible values for the properties
column.
SCOPE DESCRIPTION
Local Specifies that the scope of the cursor is local to the batch,
stored procedure, or trigger in which the cursor was created.
Examples
A. Detecting old cursors
This example returns information about cursors that have been open on the server longer than the specified time
of 36 hours.
See Also
Dynamic Management Views and Functions (Transact-SQL )
Execution Related Dynamic Management Views and Functions (Transact-SQL )
sys.dm_exec_sessions (Transact-SQL )
sys.dm_exec_describe_first_result_set (Transact-SQL)
10/1/2018 • 9 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2012) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
This dynamic management function takes a Transact-SQL statement as a parameter and describes the metadata of
the first result set for the statement.
sys.dm_exec_describe_first_result_set has the same result set definition as
sys.dm_exec_describe_first_result_set_for_object (Transact-SQL ) and is similar to sp_describe_first_result_set
(Transact-SQL ).
Transact-SQL Syntax Conventions
Syntax
sys.dm_exec_describe_first_result_set(@tsql, @params, @include_browse_information)
Arguments
@tsql
One or more Transact-SQL statements. Transact-SQL_batch may be nvarchar(n) or nvarchar(max).
@params
@params provides a declaration string for parameters for the Transact-SQL batch, similar to sp_executesql.
Parameters may be nvarchar(n) or nvarchar(max).
Is one string that contains the definitions of all parameters that have been embedded in the Transact-SQL_batch.
The string must be either a Unicode constant or a Unicode variable. Each parameter definition consists of a
parameter name and a data type. n is a placeholder that indicates additional parameter definitions. Every
parameter specified in stmt must be defined in @params. If the Transact-SQL statement or batch in the statement
does not contain parameters, @params is not required. NULL is the default value for this parameter.
@include_browse_information
If set to 1, each query is analyzed as if it has a FOR BROWSE option on the query. Additional key columns and
source table information are returned.
Table Returned
This common metadata is returned as a result set. One row for each column in the results metadata describes the
type and nullability of the column in the format shown in the following table. If the first statement does not exist
for every control path, a result set with zero rows is returned.
Remarks
This function uses the same algorithm as sp_describe_first_result_set. For more information, see
sp_describe_first_result_set (Transact-SQL ).
The following table lists the error types and their descriptions
Examples
Additional examples in the topic sp_describe_first_result_set (Transact-SQL ) can be adapted to use
sys.dm_exec_describe_first_result_set.
A. Returning information about a single Transact-SQL statement
The following code returns information about the results of a Transact-SQL statement.
USE AdventureWorks2012;
GO
SELECT * FROM sys.dm_exec_describe_first_result_set
(N'SELECT object_id, name, type_desc FROM sys.indexes', null, 0) ;
USE AdventureWorks2012;
GO
USE AdventureWorks2012;
GO
See Also
sp_describe_first_result_set (Transact-SQL )
sp_describe_undeclared_parameters (Transact-SQL )
sys.dm_exec_describe_first_result_set_for_object (Transact-SQL )
sys.dm_exec_describe_first_result_set_for_object
(Transact-SQL)
10/1/2018 • 8 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2012) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
This dynamic management function takes an @object_id as a parameter and describes the first result metadata for
the module with that ID. The @object_id specified can be the ID of a Transact-SQL stored procedure or a Transact-
SQL trigger. If it is the ID of any other object (such as a view, table, function, or CLR procedure), an error will be
specified in the error columns of the result.
sys.dm_exec_describe_first_result_set_for_object has the same result set definition as
sys.dm_exec_describe_first_result_set (Transact-SQL ) and is similar to sp_describe_first_result_set (Transact-SQL ).
Transact-SQL Syntax Conventions
Syntax
sys.dm_exec_describe_first_result_set_for_object
( @object_id , @include_browse_information )
Arguments
@object_id
The @object_id of a Transact-SQL stored procedure or a Transact-SQL trigger. @object_id is type int.
@include_browse_information
@include_browse_information is type bit. If set to 1, each query is analyzed as if it has a FOR BROWSE option on
the query. Returns additional key columns and source table information.
Table Returned
This common metadata is returned as a result set with one row for each column in the results metadata. Each row
describes the type and nullability of the column in the format described in the following section. If the first
statement does not exist for every control path, a result set with zero rows is returned.
Remarks
This function uses the same algorithm as sp_describe_first_result_set. For more information, see
sp_describe_first_result_set (Transact-SQL ).
The following table lists the error types and their descriptions
ERROR_TYPE ERROR_TYPE DESCRIPTION
Permissions
Requires permission to execute the @tsql argument.
Examples
A. Returning metadata with and without browse information
The following example creates a stored procedure named TestProc2 that returns two result sets. Then the example
demonstrates that sys.dm_exec_describe_first_result_set returns information about the first result set in the
procedure, with and without the browse information.
USE AdventureWorks2012;
GO
See Also
sp_describe_first_result_set (Transact-SQL )
sp_describe_undeclared_parameters (Transact-SQL )
sys.dm_exec_describe_first_result_set (Transact-SQL )
sys.dm_exec_distributed_request_steps (Transact-SQL)
11/14/2018 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2016) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
Holds information about all steps that compose a given PolyBase request or query. It lists one row per query step.
step_index int The position of this step in 0 to (n-1) for a request with
the sequence of steps that n steps.
make up the request.
row_count bigint Total number of rows 0 for steps that did not
changed or returned by this change or return data,
request number of rows affected
otherwise. Set to -1 for DMS
steps.
command nvarchar(4000) Holds the full text of the Any valid request string for a
command of this step. step. Truncated if longer
than 4000 characters.
See Also
PolyBase troubleshooting with dynamic management views
Dynamic Management Views and Functions (Transact-SQL )
Database Related Dynamic Management Views (Transact-SQL )
sys.dm_exec_distributed_requests (Transact-SQL)
11/14/2018 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2016) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
Holds information about all requests currently or recently active in PolyBase queries. It lists one row per
request/query.
Based on session and request ID, a user can then retrieve the actual distributed requests generated to be executed
– via sys.dm_exec_distributed_requests. For example, a query involving regular SQL and external SQL tables will
be decomposed into various statements/requests executed across the various compute nodes. To track the
distributed steps across all compute nodes, we introduce a ‘global’ execution ID which can be used to track all
operations on the compute nodes associated with one particular request and operator, respectively.
sql_handle varbinary(64) Key for this view. Unique Unique across all requests in
numeric id associated with the system.
the request.
end_time datetime Time at which the engine Null for queued or active
completed compiling the requests; otherwise, a valid
request. datetime smaller or equal to
current time.
COLUMN NAME DATA TYPE DESCRIPTION RANGE
See Also
PolyBase troubleshooting with dynamic management views
Dynamic Management Views and Functions (Transact-SQL )
Database Related Dynamic Management Views (Transact-SQL )
sys.dm_exec_distributed_sql_requests (Transact-SQL)
11/14/2018 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2016) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
Holds information about all SQL query distributions as part of a SQL step in the query. This view shows the data
for the last 1000 requests; active requests always have the data present in this view.
distribution_id int Where the step is executing. Set to -1 for requests that
run at the node scope not
the distribution scope.
row_count bigint Total number of rows 0 for steps that did not
changed or returned by this change or return data,
request number of rows affected
otherwise. Set to -1 for DMS
steps.
command nvarchar(4000) Holds the full text of the Any valid request string for a
command of this step. step. Truncated if longer
than 4000 characters.
See Also
PolyBase troubleshooting with dynamic management views
Dynamic Management Views and Functions (Transact-SQL )
Database Related Dynamic Management Views (Transact-SQL )
sys.dm_exec_dms_services (Transact-SQL)
11/14/2018 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2016) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
Holds information about all of the DMS services running on the PolyBase compute nodes. It lists one row per
service instance.
See Also
PolyBase troubleshooting with dynamic management views
Dynamic Management Views and Functions (Transact-SQL )
Database Related Dynamic Management Views (Transact-SQL )
sys.dm_exec_dms_workers (Transact-SQL)
11/14/2018 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2016) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
Holds information about all workers completing DMS steps.
This view shows the data for the last 1000 requests and active requests; active requests always have the data
present in this view.
step_index int Query step this DMS worker See step index in
is part of. sys.dm_exec_distributed_req
uest_steps (Transact-SQL).
distribution_id int
type nvarcha(32)
bytes_per_sec bigint
bytes_processed bigint
rows_processed bigint
cpu_time bigint
query_time int
buffers_available int
dms_cpid int
sql_spid int
error_id nvarchar(36)
source_info nvarchar(4000)
destination_info nvarchar(4000)
command nvarchar(4000)
See Also
PolyBase troubleshooting with dynamic management views
Dynamic Management Views and Functions (Transact-SQL )
Database Related Dynamic Management Views (Transact-SQL )
sys.dm_exec_external_operations (Transact-SQL)
11/14/2018 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2016) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
Captures information about external PolyBase operations.
operation_ name nvarchar(4000) Indicates how the status of 0-1 – multiplied by factor
job in percentage (how 100 (completed)
much is the input
consumed)
map_ progress float Indicates how the status of a 0-1 – multiplied by factor
reduce job in percentage, if 100 (completed)
any
See Also
PolyBase troubleshooting with dynamic management views
Dynamic Management Views and Functions (Transact-SQL )
Database Related Dynamic Management Views (Transact-SQL )
sys.dm_exec_external_work (Transact-SQL)
11/14/2018 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2016) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
Returns information about the workload per worker, on each compute node.
Query sys.dm_exec_external_work to identify the work spun up to communicate with the external data source (e.g.
Hadoop or external SQL Server).
APPLIES TO: SQL Server (starting with 2016) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
Returns aggregate performance statistics for cached functions. The view returns one row for each cached function
plan, and the lifetime of the row is as long as the function remains cached. When a function is removed from the
cache, the corresponding row is eliminated from this view. At that time, a Performance Statistics SQL trace event is
raised similar to sys.dm_exec_query_stats. Returns information about scalar functions, including in-memory
functions and CLR scalar functions. Does not return information about table valued functions.
In Azure SQL Database, dynamic management views cannot expose information that would impact database
containment or expose information about other databases the user has access to. To avoid exposing this
information, every row that contains data that doesn’t belong to the connected tenant is filtered out.
NOTE
An initial query of sys.dm_exec_function_stats might produce inaccurate results if there is a workload currently executing
on the server. More accurate results may be determined by rerunning the query.
Permissions
On SQL Server, requires VIEW SERVER STATE permission.
On SQL Database, requires the VIEW DATABASE STATE permission in the database.
Examples
The following example returns information about the top ten functions identified by average elapsed time.
See Also
Execution Related Dynamic Management Views and Functions (Transact-SQL )
sys.dm_exec_sql_text (Transact-SQL )
sys.dm_exec_query_stats (Transact-SQL )
sys.dm_exec_trigger_stats (Transact-SQL )
sys.dm_exec_procedure_stats (Transact-SQL )
sys.dm_exec_input_buffer (Transact-SQL)
10/1/2018 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2014 SP2) Azure SQL Database Azure SQL Data
Warehouse Parallel Data Warehouse
Returns information about statements submitted to an instance of SQL Server.
Syntax
sys.dm_exec_input_buffer ( session_id , request_id )
Arguments
session_id
Is the session id executing the batch to be looked up. session_id is smallint. session_id can be obtained from the
following dynamic management objects:
sys.dm_exec_requests
sys.dm_exec_sessions
sys.dm_exec_connections
request_id
The request_id from sys.dm_exec_requests. request_id is int.
Table Returned
COLUMN NAME DATA TYPE DESCRIPTION
Permissions
On SQL Server, if the user has VIEW SERVER STATE permission, the user will see all executing sessions on the
instance of SQL Server; otherwise, the user will see only the current session.
On SQL Database, if the user is the database owner, the user will see all executing sessions on the SQL Database;
otherwise, the user will see only the current session.
Remarks
This dynamic management function can be used in conjunction with sys.dm_exec_sessions or
sys.dm_exec_requests by doing CROSS APPLY.
Examples
A. Simple example
The following example demonstrates passing a session id (SPID ) and a request id to the function.
See Also
Execution Related Dynamic Management Views and Functions (Transact-SQL )
sys.dm_exec_sessions (Transact-SQL )
sys.dm_exec_requests (Transact-SQL )
DBCC INPUTBUFFER (Transact-SQL )
sys.dm_exec_plan_attributes (Transact-SQL)
10/1/2018 • 7 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2008) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
Returns one row per plan attribute for the plan specified by the plan handle. You can use this table-valued function
to get details about a particular plan, such as the cache key values or the number of current simultaneous
executions of the plan.
NOTE
Some of the information returned through this function maps to the sys.syscacheobjects backward compatibility view.
Syntax
sys.dm_exec_plan_attributes ( plan_handle )
Arguments
plan_handle
Uniquely identifies a query plan for a batch that has executed and whose plan resides in the plan cache.
plan_handle is varbinary(64). The plan handle can be obtained from the sys.dm_exec_cached_plans dynamic
management view.
Table Returned
COLUMN NAME DATA TYPE DESCRIPTION
From the above table, attribute can have the following values:
Permissions
On SQL Server, requires VIEW SERVER STATE permission.
On SQL Database, requires the VIEW DATABASE STATE permission in the database.
Remarks
Set Options
Copies of the same compiled plan might differ only by the value in the set_options column. This indicates that
different connections are using different sets of SET options for the same query. Using different sets of options is
usually undesirable because it can cause extra compilations, less plan reuse, and plan cache inflation because of
multiple copies of plans in the cache.
Evaluating Set Options
To translate the value returned in set_options to the options with which the plan was compiled, subtract the
values from the set_options value, starting with the largest possible value, until you reach 0. Each value you
subtract corresponds to an option that was used in the query plan. For example, if the value in set_options is 251,
the options the plan was compiled with are ANSI_NULL_DFLT_ON (128), QUOTED_IDENTIFIER (64),
ANSI_NULLS (32), ANSI_WARNINGS (16), CONCAT_NULL_YIELDS_NULL (8), Parallel Plan(2) and
ANSI_PADDING (1).
OPTION VALUE
ANSI_PADDING 1
OPTION VALUE
Parallel Plan 2
FORCEPLAN 4
CONCAT_NULL_YIELDS_NULL 8
ANSI_WARNINGS 16
ANSI_NULLS 32
QUOTED_IDENTIFIER 64
ANSI_NULL_DFLT_ON 128
ANSI_NULL_DFLT_OFF 256
NoBrowseTable 512
TriggerOneRow 1024
ResyncQuery 2048
ARITH_ABORT 4096
NUMERIC_ROUNDABORT 8192
DATEFIRST 16384
DATEFORMAT 32768
LanguageID 65536
UPON 131072
ROWCOUNT Applies To: SQL Server 2012 (11.x) to SQL Server 2017
262144
Cursors
Inactive cursors are cached in a compiled plan so that the memory used to store the cursor can be reused by
concurrent users of cursors. For example, suppose that a batch declares and uses a cursor without deallocating it.
If there are two users executing the same batch, there will be two active cursors. Once the cursors are deallocated
(potentially in different batches), the memory used to store the cursor is cached and not released. This list of
inactive cursors is kept in the compiled plan. The next time a user executes the batch, the cached cursor memory
will be reused and initialized appropriately as an active cursor.
Evaluating Cursor Options
To translate the value returned in required_cursor_options and acceptable_cursor_options to the options with
which the plan was compiled, subtract the values from the column value, starting with the largest possible value,
until you reach 0. Each value you subtract corresponds to a cursor option that was used in the query plan.
OPTION VALUE
None 0
INSENSITIVE 1
SCROLL 2
READ ONLY 4
FOR UPDATE 8
LOCAL 16
GLOBAL 32
FORWARD_ONLY 64
KEYSET 128
DYNAMIC 256
SCROLL_LOCKS 512
OPTIMISTIC 1024
STATIC 2048
FAST_FORWARD 4096
IN PLACE 8192
Examples
A. Returning the attributes for a specific plan
The following example returns all plan attributes for a specified plan. The sys.dm_exec_cached_plans dynamic
management view is queried first to obtain the plan handle for the specified plan. In the second query, replace
<plan_handle> with a plan handle value from the first query.
SELECT plan_handle, refcounts, usecounts, size_in_bytes, cacheobjtype, objtype
FROM sys.dm_exec_cached_plans;
GO
SELECT attribute, value, is_cache_key
FROM sys.dm_exec_plan_attributes(<plan_handle>);
GO
B. Returning the SET options for compiled plans and the SQL handle for cached plans
The following example returns a value representing the options that each plan was compiled with. In addition, the
SQL handle for all the cached plans is returned.
See Also
Dynamic Management Views and Functions (Transact-SQL )
Execution Related Dynamic Management Views and Functions (Transact-SQL )
sys.dm_exec_cached_plans (Transact-SQL )
sys.databases (Transact-SQL )
sys.objects (Transact-SQL )
sys.dm_exec_procedure_stats (Transact-SQL)
10/1/2018 • 5 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2008) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
Returns aggregate performance statistics for cached stored procedures. The view returns one row for each cached
stored procedure plan, and the lifetime of the row is as long as the stored procedure remains cached. When a
stored procedure is removed from the cache, the corresponding row is eliminated from this view. At that time, a
Performance Statistics SQL trace event is raised similar to sys.dm_exec_query_stats.
In Azure SQL Database, dynamic management views cannot expose information that would impact database
containment or expose information about other databases the user has access to. To avoid exposing this
information, every row that contains data that doesn’t belong to the connected tenant is filtered out.
NOTE
An initial query of sys.dm_exec_procedure_stats might produce inaccurate results if there is a workload currently
executing on the server. More accurate results may be determined by rerunning the query.
NOTE
To call this from Azure SQL Data Warehouse or Parallel Data Warehouse, use the name
sys.dm_pdw_nodes_exec_procedure_stats.
SQL_STORED_PROCEDURE
CLR_STORED_PROCEDURE
EXTENDED_STORED_PROCEDURE
COLUMN NAME DATA TYPE DESCRIPTION
1 For natively compiled stored procedures when statistics collection is enabled, worker time is collected in
milliseconds. If the query executes in less than a millisecond, the value will be 0.
Permissions
On SQL Server, requires VIEW SERVER STATE permission.
On SQL Database, requires the VIEW DATABASE STATE permission in the database.
Remarks
Statistics in the view are updated when a stored procedure execution completes.
Examples
The following example returns information about the top ten stored procedures identified by average elapsed
time.
See Also
Execution Related Dynamic Management Views and Functions (Transact-SQL )
sys.dm_exec_sql_text (Transact-SQL )
sys.dm_exec_query_plan (Transact-SQL )
sys.dm_exec_query_stats (Transact-SQL )
sys.dm_exec_trigger_stats (Transact-SQL )
sys.dm_exec_cached_plans (Transact-SQL )
sys.dm_exec_query_memory_grants (Transact-SQL)
10/1/2018 • 4 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2008) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
Returns information about all queries that have requested and are waiting for a memory grant or have been given
a memory grant. Queries that do not require a memory grant will not appear in this view. For example, sort and
hash join operations have memory grants for query execution, while queries without an ORDER BY clause will
not have a memory grant.
In Azure SQL Database, dynamic management views cannot expose information that would impact database
containment or expose information about other databases the user has access to. To avoid exposing this
information, every row that contains data that doesn’t belong to the connected tenant is filtered out. In addition,
the values in the columns scheduler_id, wait_order, pool_id, group_id are filtered; the column value is set to
NULL.
NOTE
To call this from Azure SQL Data Warehouse or Parallel Data Warehouse, use the name
sys.dm_pdw_nodes_exec_query_memory_grants.
1 = Yes
0 = No
Permissions
On SQL Server, requires VIEW SERVER STATE permission.
On Azure SQL Database, requires the VIEW DATABASE STATE permission in the database.
Remarks
A typical debugging scenario for query time-out may look like the following:
Check overall system memory status using sys.dm_os_memory_clerks, sys.dm_os_sys_info, and various
performance counters.
Check for query-execution memory reservations in sys.dm_os_memory_clerks where
type = 'MEMORYCLERK_SQLQERESERVATIONS' .
1 In this scenario, the wait type is typically RESOURCE_SEMAPHORE. For more information, see
sys.dm_os_wait_stats (Transact-SQL ).
Search cache for queries with memory grants using sys.dm_exec_cached_plans (Transact-SQL ) and
sys.dm_exec_query_plan (Transact-SQL )
If a runaway query is suspected, examine the Showplan from sys.dm_exec_query_plan and batch text from
sys.dm_exec_sql_text.
Queries that use dynamic management views that include ORDER BY or aggregates may increase memory
consumption and thus contribute to the problem they are troubleshooting.
The Resource Governor feature enables a database administrator to distribute server resources among
resource pools, up to a maximum of 64 pools. Beginning with SQL Server 2008, each pool behaves like a
small independent server instance and requires 2 semaphores. The number of rows that are returned from
sys.dm_exec_query_resource_semaphores can be up to 20 times more than the rows that are returned
in SQL Server 2005 (9.x).
See Also
sys.dm_exec_query_resource_semaphores (Transact-SQL )
sys.dm_os_wait_stats (Transact-SQL )
Execution Related Dynamic Management Views and Functions (Transact-SQL )
sys.dm_exec_query_optimizer_info (Transact-SQL)
10/1/2018 • 4 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2008) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
Returns detailed statistics about the operation of the SQL Server query optimizer. You can use this view when
tuning a workload to identify query optimization problems or improvements. For example, you can use the total
number of optimizations, the elapsed time value, and the final cost value to compare the query optimizations of the
current workload and any changes observed during the tuning process. Some counters provide data that is
relevant only for SQL Server internal diagnostic use. These counters are marked as "Internal only."
NOTE
To call this from Azure SQL Data Warehouse or Parallel Data Warehouse, use the name
sys.dm_pdw_nodes_exec_query_optimizer_info.
Permissions
On SQL Server, requires VIEW SERVER STATE permission.
On SQL Database, requires the VIEW DATABASE STATE permission in the database.
Remarks
sys.dm_exec_query_optimizer_info contains the following properties (counters). All occurrence values are
cumulative and are set to 0 at system restart. All values for value fields are set to NULL at system restart. All value-
column values that specify an average use the occurrence value from the same row as the denominator in the
calculation of the average. All query optimizations are measured when SQL Server determines changes to
dm_exec_query_optimizer_info, including both user- and system-generated queries. Execution of an already-
cached plan does not change values in dm_exec_query_optimizer_info, only optimizations are significant.
elapsed time Total number of optimizations. Average elapsed time per optimization
of an individual statement (query), in
seconds.
order hint Number of times a force order hint was Not applicable
specified.
join hint Number of times the join algorithm was Not applicable
forced by a join hint.
maximum DOP Total number of optimizations. Average effective MAXDOP value for an
optimized plan. By default, effective
MAXDOP is determined by the max
degree of parallelism server
configuration option, and may be
overridden for a specific query by the
value of the MAXDOP query hint.
indexed views matched Number of optimizations where one or Average number of views matched.
more indexed views have been
matched.
indexed views used Number of optimizations where one or Average number of views used.
more indexed views are used in the
output plan after being matched.
indexed views updated Number of optimizations of a DML Average number of views maintained.
statement that produce a plan that
maintains one or more indexed views.
Examples
A. Viewing statistics on optimizer execution
What are the current optimizer execution statistics for this instance of SQL Server?
SELECT (SELECT CAST (occurrence AS float) FROM sys.dm_exec_query_optimizer_info WHERE counter = 'contains
subquery') /
(SELECT CAST (occurrence AS float)
FROM sys.dm_exec_query_optimizer_info WHERE counter = 'optimizations')
AS ContainsSubqueryFraction;
See Also
Dynamic Management Views and Functions (Transact-SQL )
Execution Related Dynamic Management Views and Functions (Transact-SQL )
sys.dm_exec_query_optimizer_memory_gateways
(Transact-SQL)
11/12/2018 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2016) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
Returns the current status of resource semaphores used to throttle concurrent query optimization.
Permissions
SQL Server requires VIEW SERVER STATE permission on the server.
Azure SQL Database requires the VIEW DATABASE STATE permission in the database.
Remarks
SQL Server uses a tiered gateway approach to throttle the number of permitted concurrent compilations. Three
gateways are used, including small, medium and big. Gateways help prevent the exhausting of overall memory
resources by larger compilation memory-requiring consumers.
Waits on a gateway result in delayed compilation. In addition to delays in compilation, throttled requests will have
an associated RESOURCE_SEMAPHORE_QUERY_COMPILE wait type accumulation. The
RESOURCE_SEMAPHORE_QUERY_COMPILE wait type may indicate that queries are using a large amount of
memory for compilation and that memory has been exhausted, or alternatively there is sufficient memory
available overall, however available units in a specific gateway have been exhausted. The output of
sys.dm_exec_query_optimizer_memory_gateways can be used to troubleshoot scenarios where there was
insufficient memory to compile a query execution plan.
Examples
A. Viewing statistics on resource semaphores
What are the current optimizer memory gateway statistics for this instance of SQL Server?
See Also
Dynamic Management Views and Functions (Transact-SQL )
Execution Related Dynamic Management Views and Functions (Transact-SQL )
How to use the DBCC MEMORYSTATUS command to monitor memory usage on SQL Server 2005 Large query
compilation waits on RESOURCE_SEMAPHORE_QUERY_COMPILE in SQL Server 2014
sys.dm_exec_query_parallel_workers (Transact-SQL)
10/1/2018 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2016) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
Returns worker availability information per node.
Permissions
On SQL Server, requires VIEW SERVER STATE permission.
On SQL Database, requires the VIEW DATABASE STATE permission in the database.
Examples
A. Viewing current parallel worker availability
See Also
Dynamic Management Views and Functions (Transact-SQL )
Execution Related Dynamic Management Views and Functions (Transact-SQL )
sys.dm_os_workers (Transact-SQL )
sys.dm_exec_query_plan (Transact-SQL)
11/14/2018 • 6 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2008) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
Returns the Showplan in XML format for the batch specified by the plan handle. The plan specified by the plan
handle can either be cached or currently executing.
The XML schema for the Showplan is published and available at this Microsoft Web site. It is also available in the
directory where SQL Server is installed.
Transact-SQL Syntax Conventions
Syntax
sys.dm_exec_query_plan ( plan_handle )
Arguments
plan_handle
Uniquely identifies a query plan for a batch that is cached or is currently executing.
plan_handle is varbinary(64). plan_handle can be obtained from the following dynamic management objects:
sys.dm_exec_cached_plans
sys.dm_exec_query_stats
sys.dm_exec_requests
Table Returned
COLUMN NAME DATA TYPE DESCRIPTION
Column is nullable.
Column is nullable.
COLUMN NAME DATA TYPE DESCRIPTION
Column is nullable.
0 = not encrypted
1 = encrypted
Column is nullable.
Remarks
Under the following conditions, no Showplan output is returned in the query_plan column of the returned table
for sys.dm_exec_query_plan:
If the query plan that is specified by using plan_handle has been evicted from the plan cache, the
query_plan column of the returned table is null. For example, this condition may occur if there is a time
delay between when the plan handle was captured and when it was used with sys.dm_exec_query_plan.
Some Transact-SQL statements are not cached, such as bulk operation statements or statements
containing string literals larger than 8 KB in size. XML Showplans for such statements cannot be retrieved
by using sys.dm_exec_query_plan unless the batch is currently executing because they do not exist in
the cache.
If a Transact-SQL batch or stored procedure contains a call to a user-defined function or a call to dynamic
SQL, for example using EXEC (string), the compiled XML Showplan for the user-defined function is not
included in the table returned by sys.dm_exec_query_plan for the batch or stored procedure. Instead,
you must make a separate call to sys.dm_exec_query_plan for the plan handle that corresponds to the
user-defined function.
When an ad hoc query uses simple or forced parameterization, the query_plan column will contain only
the statement text and not the actual query plan. To return the query plan, call sys.dm_exec_query_plan
for the plan handle of the prepared parameterized query. You can determine whether the query was
parameterized by referencing the sql column of the sys.syscacheobjects view or the text column of the
sys.dm_exec_sql_text dynamic management view.
Due to a limitation in the number of nested levels allowed in the xml data type,
sys.dm_exec_query_plan cannot return query plans that meet or exceed 128 levels of nested elements.
In earlier versions of SQL Server, this condition prevented the query plan from returning and generates
error 6335. In SQL Server 2005 (9.x) Service Pack 2 and later versions, the query_plan column returns
NULL. You can use the sys.dm_exec_text_query_plan (Transact-SQL ) dynamic management function to
return the output of the query plan in text format.
Permissions
To execute sys.dm_exec_query_plan, a user must be a member of the sysadmin fixed server role or have the
VIEW SERVER STATE permission on the server.
Examples
The following examples show how to use the sys.dm_exec_query_plan dynamic management view.
To view the XML Showplans, execute the following queries in the Query Editor of SQL Server Management
Studio, then click ShowPlanXML in the query_plan column of the table returned by
sys.dm_exec_query_plan. The XML Showplan displays in the Management Studio summary pane. To save the
XML Showplan to a file, right-click ShowPlanXML in the query_plan column, click Save Results As, name the
file in the format <file_name>.sqlplan; for example, MyXMLShowplan.sqlplan.
A. Retrieve the cached query plan for a slow-running Transact-SQL query or batch
Query plans for various types of Transact-SQL batches, such as ad hoc batches, stored procedures, and user-
defined functions, are cached in an area of memory called the plan cache. Each cached query plan is identified by
a unique identifier called a plan handle. You can specify this plan handle with the sys.dm_exec_query_plan
dynamic management view to retrieve the execution plan for a particular Transact-SQL query or batch.
If a Transact-SQL query or batch runs a long time on a particular connection to SQL Server, retrieve the
execution plan for that query or batch to discover what is causing the delay. The following example shows how
to retrieve the XML Showplan for a slow -running query or batch.
NOTE
To run this example, replace the values for session_id and plan_handle with values specific to your server.
First, retrieve the server process ID (SPID ) for the process that is executing the query or batch by using the
sp_who stored procedure:
USE master;
GO
exec sp_who;
GO
The result set that is returned by sp_who indicates that the SPID is 54 . You can use the SPID with the
sys.dm_exec_requests dynamic management view to retrieve the plan handle by using the following query:
USE master;
GO
SELECT * FROM sys.dm_exec_requests
WHERE session_id = 54;
GO
The table that is returned by sys.dm_exec_requests indicates that the plan handle for the slow -running query
or batch is 0x06000100A27E7C1FA821B10600 , which you can specify as the plan_handle argument with
sys.dm_exec_query_plan to retrieve the execution plan in XML format as follows. The execution plan in XML
format for the slow -running query or batch is contained in the query_plan column of the table returned by
sys.dm_exec_query_plan .
USE master;
GO
SELECT * FROM sys.dm_exec_query_plan (0x06000100A27E7C1FA821B10600);
GO
USE master;
GO
SELECT * FROM sys.dm_exec_cached_plans cp CROSS APPLY sys.dm_exec_query_plan(cp.plan_handle);
GO
C. Retrieve every query plan for which the server has gathered query statistics from the plan cache
To retrieve a snapshot of all query plans for which the server has gathered statistics that currently reside in the
plan cache, retrieve the plan handles of these plans in the cache by querying the sys.dm_exec_query_stats
dynamic management view. The plan handles are stored in the plan_handle column of sys.dm_exec_query_stats .
Then use the CROSS APPLY operator to pass the plan handles to sys.dm_exec_query_plan as follows. The XML
Showplan output for each plan for which the server has gathered statistics currently in the plan cache is in the
query_plan column of the table that is returned.
USE master;
GO
SELECT * FROM sys.dm_exec_query_stats qs CROSS APPLY sys.dm_exec_query_plan(qs.plan_handle);
GO
D. Retrieve information about the top five queries by average CPU time
The following example returns the plans and average CPU time for the top five queries.
See Also
Dynamic Management Views and Functions (Transact-SQL )
sys.dm_exec_cached_plans (Transact-SQL )
sys.dm_exec_query_stats (Transact-SQL )
sys.dm_exec_requests (Transact-SQL )
sp_who (Transact-SQL )
Showplan Logical and Physical Operators Reference
sys.dm_exec_text_query_plan (Transact-SQL )
sys.dm_exec_query_profiles (Transact-SQL)
10/1/2018 • 4 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2014) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
Monitors real time query progress while the query is in execution. For example, use this DMV to determine which
part of the query is running slow. Join this DMV with other system DMVs using the columns identified in the
description field. Or, join this DMV with other performance counters (such as Performance Monitor, xperf) by
using the timestamp columns.
Table Returned
The counters returned are per operator per thread. The results are dynamic and do not match the results of
existing options such as SET STATISTICS XML ON which only create output when the query is finished.
General Remarks
If the query plan node does not have any IO, all the IO -related counters are set to NULL.
The IO -related counters reported by this DMV are more granular than the ones reported by SET STATISTICS IO
in the following two ways:
SET STATISTICS IO groups the counters for all IO to a given table together. With this DMV you will get
separate counters for every node in the query plan that performs IO to the table.
If there is a parallel scan, this DMV reports counters for each of the parallel threads working on the scan.
Starting with SQL Server 2016 (13.x) SP1, the standard query execution statistics profiling infrastructure
exists side-by-side with a lightweight query execution statistics profiling infrastructure. The new query
execution statistics profiling infrastructure dramatically reduces performance overhead of collecting per-
operator query execution statistics, such as actual number of rows. This feature can be enabled either using
global startup trace flag 7412, or is automatically turned on when query_thread_profile extended event is
used.
NOTE
CPU and elapsed times are not supported under the lightweight query execution statistics profiling infrastructure to reduce
performance impact.
SET STATISTICS XML ON and SET STATISTICS PROFILE ON always use the legacy query execution statistics
profiling infrastructure.
Permissions
On SQL Server, requires VIEW SERVER STATE permission.
On SQL Database, requires the VIEW DATABASE STATE permission in the database.
Examples
Step 1: Login to a session in which you plan to run the query you will analyze with sys.dm_exec_query_profiles. To
configure the query for profiling use SET STATISTICS PROFILE ON. Run your query in this same session.
--Configure query for profiling with sys.dm_exec_query_profiles
SET STATISTICS PROFILE ON;
GO
--Or enable query profiling globally under SQL Server 2016 SP1 or above
DBCC TRACEON (7412, -1);
GO
--Next, run your query in this session, or in any other session if query profiling has been enabled globally
Step 2: Login to a second session that is different from the session in which your query is running.
The following statement summarizes the progress made by the query currently running in session 54. To do this, it
calculates the total number of output rows from all threads for each node, and compares it to the estimated
number of output rows for that node.
--Run this in a different session than the session in which your query is running.
--Note that you may need to change session id 54 below with the session id you want to monitor.
SELECT node_id,physical_operator_name, SUM(row_count) row_count,
SUM(estimate_row_count) AS estimate_row_count,
CAST(SUM(row_count)*100 AS float)/SUM(estimate_row_count)
FROM sys.dm_exec_query_profiles
WHERE session_id=54
GROUP BY node_id,physical_operator_name
ORDER BY node_id;
See Also
Dynamic Management Views and Functions (Transact-SQL )
Execution Related Dynamic Management Views and Functions (Transact-SQL )
sys.dm_exec_query_resource_semaphores (Transact-
SQL)
10/1/2018 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2008) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
Returns the information about the current query-resource semaphore status in SQL Server.
sys.dm_exec_query_resource_semaphores provides general query-execution memory status and allows you to
determine whether the system can access enough memory. This view complements memory information obtained
from sys.dm_os_memory_clerks to provide a complete picture of server memory status.
sys.dm_exec_query_resource_semaphores returns one row for the regular resource semaphore and another
row for the small-query resource semaphore. There are two requirements for a small-query semaphore:
The memory grant requested should be less than 5 MB
The query cost should be less than 3 cost units
NOTE
To call this from Azure SQL Data Warehouse or Parallel Data Warehouse, use the name
sys.dm_pdw_nodes_exec_query_resource_semaphores.
Permissions
On SQL Server, requires VIEW SERVER STATE permission.
On SQL Database, requires the VIEW DATABASE STATE permission in the database.
Remarks
Queries that use dynamic management views that include ORDER BY or aggregates might increase memory
consumption and thus contribute to the problem they are troubleshooting.
Use sys.dm_exec_query_resource_semaphores for troubleshooting but do not include it in applications that will
use future versions of SQL Server.
The Resource Governor feature enables a database administrator to distribute server resources among resource
pools, up to a maximum of 64 pools. In SQL Server 2012 (11.x) and higher, each pool behaves like a small
independent server instance and requires 2 semaphores.
See Also
Execution Related Dynamic Management Views and Functions (Transact-SQL )
sys.dm_exec_query_memory_grants (Transact-SQL )
sys.dm_exec_query_statistics_xml (Transact-SQL)
11/14/2018 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2016) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
Returns query execution plan for in-flight requests. Use this DMV to retrieve showplan XML with transient
statistics.
Syntax
sys.dm_exec_query_statistics_xml(session_id)
Arguments
session_id
Is the session id executing the batch to be looked up. session_id is smallint. session_id can be obtained from the
following dynamic management objects:
sys.dm_exec_requests
sys.dm_exec_sessions
sys.dm_exec_connections
Table Returned
COLUMN NAME DATA TYPE DESCRIPTION
Remarks
This system function is available starting with SQL Server 2016 (13.x) SP1.
This system function works under both standard and lightweight query execution statistics profiling
infrastructure.
Standard statistics profiling infrastructure can be enabled by using:
SET STATISTICS XML ON
SET STATISTICS PROFILE ON
the query_post_execution_showplan extended event.
Lightweight statistics profiling infrastructure is available in SQL Server 2014 (12.x) SP2 and SQL Server 2016
(13.x) and can be enabled:
Globally by using trace flag 7412.
Using the query_thread_profile extended event.
NOTE
Once enabled by trace flag 7412, lightweight profiling will be enabled to any consumer of the query execution statistics
profiling infrastructure instead of standard profiling, such as the DMV sys.dm_exec_query_profiles. However, standard
profiling is still used for SET STATISTICS XML, Include Actual Plan action in Management Studio, and
query_post_execution_showplan xEvent.
IMPORTANT
In TPC-C like workload tests, enabling the lightweight statistics profiling infrastructure adds a 1.5 to 2 percent overhead. In
contrast, the standard statistics profiling infrastructure can add up to 90 percent overhead for the same workload scenario.
Permissions
Requires VIEW SERVER STATE permission on the server.
Examples
A. Looking at live query plan and execution statistics for a running batch
The following example queries sys.dm_exec_requests to find the interesting query and copy its session_id from
the output.
Then, to obtain the live query plan and execution statistics, use the copied session_id with system function
sys.dm_exec_query_statistics_xml.
--Run this in a different session than the session in which your query is running.
SELECT * FROM sys.dm_exec_query_statistics_xml(< copied session_id >);
GO
--Run this in a different session than the session in which your query is running.
SELECT * FROM sys.dm_exec_requests
CROSS APPLY sys.dm_exec_query_statistics_xml(session_id);
GO
See Also
Trace Flags
Dynamic Management Views and Functions (Transact-SQL )
Database Related Dynamic Management Views (Transact-SQL )
sys.dm_exec_query_stats (Transact-SQL)
10/1/2018 • 14 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2008) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
Returns aggregate performance statistics for cached query plans in SQL Server. The view contains one row per
query statement within the cached plan, and the lifetime of the rows are tied to the plan itself. When a plan is
removed from the cache, the corresponding rows are eliminated from this view.
NOTE
An initial query of sys.dm_exec_query_stats might produce inaccurate results if there is a workload currently executing
on the server. More accurate results may be determined by rerunning the query.
NOTE
To call this from Azure SQL Data Warehouse or Parallel Data Warehouse, use the name
sys.dm_pdw_nodes_exec_query_stats.
NOTE
1 For natively compiled stored procedures when statistics collection is enabled, worker time is collected in milliseconds. If
the query executes in less than one millisecond, the value will be 0.
Permissions
On SQL Server, requires VIEW SERVER STATE permission.
On SQL Database, requires the VIEW DATABASE STATE permission in the database.
Remarks
Statistics in the view are updated when a query is completed.
Examples
A. Finding the TOP N queries
The following example returns information about the top five queries ranked by average CPU time. This example
aggregates the queries according to their query hash so that logically equivalent queries are grouped by their
cumulative resource consumption.
SELECT qs.execution_count,
SUBSTRING(qt.text,qs.statement_start_offset/2 +1,
(CASE WHEN qs.statement_end_offset = -1
THEN LEN(CONVERT(nvarchar(max), qt.text)) * 2
ELSE qs.statement_end_offset end -
qs.statement_start_offset
)/2
) AS query_text,
qt.dbid, dbname= DB_NAME (qt.dbid), qt.objectid,
qs.total_rows, qs.last_rows, qs.min_rows, qs.max_rows
FROM sys.dm_exec_query_stats AS qs
CROSS APPLY sys.dm_exec_sql_text(qs.sql_handle) AS qt
WHERE qt.text like '%SELECT%'
ORDER BY qs.execution_count DESC;
See also
Execution Related Dynamic Management Views and Functions (Transact-SQL )
sys.dm_exec_sql_text (Transact-SQL )
sys.dm_exec_query_plan (Transact-SQL )
sys.dm_exec_procedure_stats (Transact-SQL )
sys.dm_exec_trigger_stats (Transact-SQL )
sys.dm_exec_cached_plans (Transact-SQL )
sys.dm_exec_requests (Transact-SQL)
10/1/2018 • 7 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2008) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
Returns information about each request that is executing within SQL Server.
NOTE
To execute code that is outside SQL Server (for example, extended stored procedures and distributed queries), a thread
has to execute outside the control of the non-preemptive scheduler. To do this, a worker switches to preemptive mode.
Time values returned by this dynamic management view do not include time spent in preemptive mode.
Background
Running
Runnable
Sleeping
Suspended
Is not nullable.
COLUMN NAME DATA TYPE DESCRIPTION
SELECT
INSERT
UPDATE
DELETE
BACKUP LOG
BACKUP DATABASE
DBCC
FOR
LOCK MONITOR
CHECKPOINTLAZY
WRITER
Is not nullable.
Is not nullable.
Is not nullable.
Is not nullable.
Is not nullable.
Is not nullable.
Is not nullable.
Otherwise, it is 0.
Is not nullable.
Is not nullable.
Is not nullable.
COLUMN NAME DATA TYPE DESCRIPTION
0 = Unspecified
1 = ReadUncomitted
2 = ReadCommitted
3 = Repeatable
4 = Serializable
5 = Snapshot
Permissions
If the user has VIEW SERVER STATE permission on the server, the user will see all executing sessions on the
instance of SQL Server; otherwise, the user will see only the current session. VIEW SERVER STATE cannot be
granted in SQL Database so sys.dm_exec_requests is always limited to the current connection.
Examples
A. Finding the query text for a running batch
The following example queries sys.dm_exec_requests to find the interesting query and copy its sql_handle
from the output.
Then, to obtain the statement text, use the copied sql_handle with system function
sys.dm_exec_sql_text(sql_handle) .
Then, to find lock information, use the copied transaction_id with the system function sys.dm_tran_locks.
See Also
Dynamic Management Views and Functions (Transact-SQL )
Execution Related Dynamic Management Views and Functions (Transact-SQL )
sys.dm_os_memory_clerks (Transact-SQL )
sys.dm_os_sys_info (Transact-SQL )
sys.dm_exec_query_memory_grants (Transact-SQL )
sys.dm_exec_query_plan (Transact-SQL )
sys.dm_exec_sql_text (Transact-SQL )
sys.dm_exec_session_wait_stats (Transact-SQL)
10/1/2018 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2016) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
Returns information about all the waits encountered by threads that executed for each session. You can use this
view to diagnose performance issues with the SQL Server session and also with specific queries and batches. This
view returns session the same information that is aggregated for sys.dm_os_wait_stats (Transact-SQL ) but
provides the session_id number as well.
Applies to: SQL Server ( SQL Server 2016 (13.x) through SQL Server 2017).
Remarks
This DMV resets the information for a session when the session is opened, or when the session is reset (if
connection pooling),
For information about the wait types, see sys.dm_os_wait_stats (Transact-SQL ).
Permissions
If the user has VIEW SERVER STATE permission on the server, the user will see all executing sessions on the
instance of SQL Server; otherwise, the user will see only the current session.
See Also
Dynamic Management Views and Functions (Transact-SQL )
SQL Server Operating System Related Dynamic Management Views (Transact-SQL )
sys.dm_os_wait_stats (Transact-SQL )
sys.dm_exec_sessions (Transact-SQL)
10/1/2018 • 7 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2008) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
Returns one row per authenticated session on SQL Server. sys.dm_exec_sessions is a server-scope view that
shows information about all active user connections and internal tasks. This information includes client version,
client program name, client login time, login user, current session setting, and more. Use sys.dm_exec_sessions to
first view the current system load and to identify a session of interest, and then learn more information about
that session by using other dynamic management views or dynamic management functions.
The sys.dm_exec_connections, sys.dm_exec_sessions, and sys.dm_exec_requests dynamic management views
map to the sys.sysprocesses system table.
NOTE: To call this from Azure SQL Data Warehouse or Parallel Data Warehouse, use the name
sys.dm_pdw_nodes_exec_sessions.
Is not nullable.
0 = Unspecified
1 = ReadUncomitted
2 = ReadCommitted
3 = Repeatable
4 = Serializable
5 = Snapshot
Is not nullable.
Permissions
Everyone can see their own session information.
SQL Server: Requires VIEW SERVER STATE permission on SQL Server to see all sessions on the server.
SQL Database: Requires VIEW DATABASE STATE to see all connections to the current database.
VIEW DATABASE STATE cannot be granted in the master database.
Remarks
When the common criteria compliance enabled server configuration option is enabled, logon statistics are
displayed in the following columns.
last_successful_logon
last_unsuccessful_logon
unsuccessful_logons
If this option is not enabled, these columns will return null values. For more information about how to set
this server configuration option, see common criteria compliance enabled Server Configuration Option.
The admin connections on Azure SQL Database will see one row per authenticated session. The "sa" sessions
that appear in the resultset, do not have any impact on the user quota for sessions. The non-admin connections
will only see information related to their database user sessions.
Relationship Cardinalities
FROM TO ON/APPLY RELATIONSHIP
Examples
A. Finding users that are connected to the server
The following example finds the users that are connected to the server and returns the number of sessions for
each user.
USE master;
GO
SELECT creation_time ,cursor_id
,name ,c.session_id ,login_name
FROM sys.dm_exec_cursors(0) AS c
JOIN sys.dm_exec_sessions AS s
ON c.session_id = s.session_id
WHERE DATEDIFF(mi, c.creation_time, GETDATE()) > 5;
SELECT s.*
FROM sys.dm_exec_sessions AS s
WHERE EXISTS
(
SELECT *
FROM sys.dm_tran_session_transactions AS t
WHERE t.session_id = s.session_id
)
AND NOT EXISTS
(
SELECT *
FROM sys.dm_exec_requests AS r
WHERE r.session_id = s.session_id
);
SELECT
c.session_id, c.net_transport, c.encrypt_option,
c.auth_scheme, s.host_name, s.program_name,
s.client_interface_name, s.login_name, s.nt_domain,
s.nt_user_name, s.original_login_name, c.connect_time,
s.login_time
FROM sys.dm_exec_connections AS c
JOIN sys.dm_exec_sessions AS s
ON c.session_id = s.session_id
WHERE c.session_id = @@SPID;
See Also
Dynamic Management Views and Functions (Transact-SQL )
Execution Related Dynamic Management Views and Functions (Transact-SQL )
sys.dm_exec_sql_text (Transact-SQL)
10/1/2018 • 3 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2008) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
Returns the text of the SQL batch that is identified by the specified sql_handle. This table-valued function
replaces the system function fn_get_sql.
Syntax
sys.dm_exec_sql_text(sql_handle | plan_handle)
Arguments
sql_handle
Is the SQL handle of the batch to be looked up. sql_handle is varbinary(64). sql_handle can be obtained from
the following dynamic management objects:
sys.dm_exec_query_stats
sys.dm_exec_requests
sys.dm_exec_cursors
sys.dm_exec_xml_handles
sys.dm_exec_query_memory_grants
sys.dm_exec_connections
plan_handle
Uniquely identifies a query plan for a batch that is cached or is currently executing. plan_handle is
varbinary(64). plan_handle can be obtained from the following dynamic management objects:
sys.dm_exec_cached_plans
sys.dm_exec_query_stats
sys.dm_exec_requests
Table Returned
COLUMN NAME DATA TYPE DESCRIPTION
Permissions
Requires VIEW SERVER STATE permission on the server.
Remarks
For ad hoc queries, the SQL handles are hash values based on the SQL text being submitted to the server, and
can originate from any database.
For database objects such as stored procedures, triggers or functions, the SQL handles are derived from the
database ID, object ID, and object number.
Plan handle is a hash value derived from the compiled plan of the entire batch.
NOTE
dbid cannot be determined from sql_handle for ad hoc queries. To determine dbid for ad hoc queries, use plan_handle
instead.
Examples
A. Conceptual Example
The following is a basic example to illustrate passing a sql_handle either directly or with CROSS APPLY.
1. Create activity.
Execute the following T-SQL in a new query window in SQL Server Management Studio.
-- Identify current spid (session_id)
SELECT @@SPID;
GO
-- Create activity
WAITFOR DELAY '00:02:00';
SELECT t.*
FROM sys.dm_exec_requests AS r
CROSS APPLY sys.dm_exec_sql_text(r.sql_handle) AS t
WHERE session_id = 59 -- modify this value with your actual spid
-- acquire sql_handle
SELECT sql_handle FROM sys.dm_exec_requests WHERE session_id = 59 -- modify this value with
your actual spid
B. Obtain information about the top five queries by average CPU time
The following example returns the text of the SQL statement and average CPU time for the top five queries.
See also
Dynamic Management Views and Functions (Transact-SQL )
Execution Related Dynamic Management Views and Functions (Transact-SQL )
sys.dm_exec_query_stats (Transact-SQL )
sys.dm_exec_requests (Transact-SQL )
sys.dm_exec_cursors (Transact-SQL )
sys.dm_exec_xml_handles (Transact-SQL )
sys.dm_exec_query_memory_grants (Transact-SQL )
Using APPLY
sys.dm_exec_text_query_plan (Transact-SQL )
sys.dm_exec_text_query_plan (Transact-SQL)
11/14/2018 • 6 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2008) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
Returns the Showplan in text format for a Transact-SQL batch or for a specific statement within the batch. The
query plan specified by the plan handle can either be cached or currently executing. This table-valued function is
similar to sys.dm_exec_query_plan (Transact-SQL ) , but has the following differences:
The output of the query plan is returned in text format.
The output of the query plan is not limited in size.
Individual statements within the batch can be specified.
Applies to: SQL Server ( SQL Server 2008 through current version), Azure SQL Database.
Transact-SQL Syntax Conventions
Syntax
sys.dm_exec_text_query_plan
(
plan_handle
, { statement_start_offset | 0 | DEFAULT }
, { statement_end_offset | -1 | DEFAULT }
)
Arguments
plan_handle
Uniquely identifies a query plan for a batch that is cached or is currently executing. plan_handle is varbinary(64).
The plan handle can be obtained from the following dynamic management objects:
sys.dm_exec_cached_plans
sys.dm_exec_query_stats
sys.dm_exec_requests
statement_start_offset | 0 | DEFAULT
Indicates, in bytes, the starting position of the query that the row describes within the text of its batch or persisted
object. statement_start_offset is int. A value of 0 indicates the beginning of the batch. The default value is 0.
The statement start offset can be obtained from the following dynamic management objects:
sys.dm_exec_query_stats
sys.dm_exec_requests
statement_end_offset | -1 | DEFAULT
Indicates, in bytes, the ending position of the query that the row describes within the text of its batch or persisted
object.
statement_start_offset is int.
A value of -1 indicates the end of the batch. The default value is -1.
Table Returned
COLUMN NAME DATA TYPE DESCRIPTION
Column is nullable.
Column is nullable.
Column is nullable.
0 = not encrypted
1 = encrypted
Column is nullable.
Remarks
Under the following conditions, no Showplan output is returned in the plan column of the returned table for
sys.dm_exec_text_query_plan:
If the query plan that is specified by using plan_handle has been evicted from the plan cache, the
query_plan column of the returned table is null. For example, this condition may occur if there is a time
delay between when the plan handle was captured and when it was used with
sys.dm_exec_text_query_plan.
Some Transact-SQL statements are not cached, such as bulk operation statements or statements
containing string literals larger than 8 KB in size. Showplans for such statements cannot be retrieved by
using sys.dm_exec_text_query_plan because they do not exist in the cache.
If a Transact-SQL batch or stored procedure contains a call to a user-defined function or a call to dynamic
SQL, for example using EXEC (string), the compiled XML Showplan for the user-defined function is not
included in the table returned by sys.dm_exec_text_query_plan for the batch or stored procedure.
Instead, you must make a separate call to sys.dm_exec_text_query_plan for the plan_handle that
corresponds to the user-defined function.
When an ad hoc query uses simple or forced parameterization, the query_plan column will contain only the
statement text and not the actual query plan. To return the query plan, call sys.dm_exec_text_query_plan for the
plan handle of the prepared parameterized query. You can determine whether the query was parameterized by
referencing the sql column of the sys.syscacheobjects view or the text column of the sys.dm_exec_sql_text
dynamic management view.
Permissions
To execute sys.dm_exec_text_query_plan, a user must be a member of the sysadmin fixed server role or have
the VIEW SERVER STATE permission on the server.
Examples
A. Retrieving the cached query plan for a slow-running Transact-SQL query or batch
If a Transact-SQL query or batch runs a long time on a particular connection to SQL Server, retrieve the execution
plan for that query or batch to discover what is causing the delay. The following example shows how to retrieve
the Showplan for a slow -running query or batch.
NOTE
To run this example, replace the values for session_id and plan_handle with values specific to your server.
First, retrieve the server process ID (SPID ) for the process that is executing the query or batch by using the
sp_who stored procedure:
USE master;
GO
EXEC sp_who;
GO
The result set that is returned by sp_who indicates that the SPID is 54 . You can use the SPID with the
sys.dm_exec_requests dynamic management view to retrieve the plan handle by using the following query:
USE master;
GO
SELECT * FROM sys.dm_exec_requests
WHERE session_id = 54;
GO
The table that is returned by sys.dm_exec_requests indicates that the plan handle for the slow -running query or
batch is 0x06000100A27E7C1FA821B10600 . The following example returns the query plan for the specified plan handle
and uses the default values 0 and -1 to return all statements in the query or batch.
USE master;
GO
SELECT query_plan
FROM sys.dm_exec_text_query_plan (0x06000100A27E7C1FA821B10600,0,-1);
GO
USE master;
GO
SELECT *
FROM sys.dm_exec_cached_plans AS cp
CROSS APPLY sys.dm_exec_text_query_plan(cp.plan_handle, DEFAULT, DEFAULT);
GO
C. Retrieving every query plan for which the server has gathered query statistics from the plan cache
To retrieve a snapshot of all query plans for which the server has gathered statistics that currently reside in the
plan cache, retrieve the plan handles of these plans in the cache by querying the sys.dm_exec_query_stats
dynamic management view. The plan handles are stored in the plan_handle column of sys.dm_exec_query_stats .
Then use the CROSS APPLY operator to pass the plan handles to sys.dm_exec_text_query_plan as follows. The
Showplan output for each plan is in the query_plan column of the table that is returned.
USE master;
GO
SELECT * FROM sys.dm_exec_query_stats AS qs
CROSS APPLY sys.dm_exec_text_query_plan(qs.plan_handle, qs.statement_start_offset, qs.statement_end_offset);
GO
D. Retrieving information about the top five queries by average CPU time
The following example returns the query plans and average CPU time for the top five queries. The
sys.dm_exec_text_query_plan function specifies the default values 0 and -1 to return all statements in the batch
in the query plan.
See Also
sys.dm_exec_query_plan (Transact-SQL )
sys.dm_exec_trigger_stats (Transact-SQL)
10/1/2018 • 3 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2008) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
Returns aggregate performance statistics for cached triggers. The view contains one row per trigger, and the
lifetime of the row is as long as the trigger remains cached. When a trigger is removed from the cache, the
corresponding row is eliminated from this view. At that time, a Performance Statistics SQL trace event is raised
similar to sys.dm_exec_query_stats.
TR = SQL trigger
CLR_TRIGGER
SQL_TRIGGER
Remarks
In SQL Database, dynamic management views cannot expose information that would impact database
containment or expose information about other databases the user has access to. To avoid exposing this
information, every row that contains data that doesn’t belong to the connected tenant is filtered out.
Statistics in the view are updated when a query is completed.
Permissions
On SQL Server, requires VIEW SERVER STATE permission.
On SQL Database, requires the VIEW DATABASE STATE permission in the database.
Examples
The following example returns information about the top five triggers identified by average elapsed time.
See Also
Execution Related Dynamic Management Views and Functions (Transact-SQL )
sys.dm_exec_sql_text (Transact-SQL )
sys.dm_exec_query_stats (Transact-SQL )
sys.dm_exec_procedure_stats (Transact-SQL )
sys.dm_exec_cached_plans (Transact-SQL )
sys.dm_exec_valid_use_hints (Transact-SQL)
10/23/2018 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2016) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
Returns USE HINT supported hint names. It lists one hint name per row.
Use this DMV to see the list of all supported hints under the USE HINT notation.
See Also
Dynamic Management Views and Functions (Transact-SQL )
Database Related Dynamic Management Views (Transact-SQL )
sys.dm_exec_xml_handles (Transact-SQL)
10/1/2018 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2008) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
Returns information about active handles that have been opened by sp_xml_preparedocument.
Syntax
dm_exec_xml_handles (session_id | 0 )
Arguments
session_id | 0,
ID of the session. If session_id is specified, this function returns information about XML handles in the specified
session.
If 0 is specified, the function returns information about all XML handles for all sessions.
Table Returned
COLUMN NAME DATA TYPE DESCRIPTION
Remarks
The lifetime of sql_handles used to retrieve the SQL text that executed a call to sp_xml_preparedocument
outlives the cached plan used to execute the query. If the query text is not available in the cache, the data cannot
be retrieved using the information provided in the function result. This can occur if you are running many large
batches.
Permissions
Requires VIEW SERVER STATE permission on the server to see all sessions or session IDs that are not owned by
the caller. A caller can always see the data for his or her own current session ID.
Examples
The following example selects all active handles.
See Also
Dynamic Management Views and Functions (Transact-SQL )
Execution Related Dynamic Management Views and Functions (Transact-SQL )
sp_xml_preparedocument (Transact-SQL )
sp_xml_removedocument (Transact-SQL )
sys.dm_external_script_execution_stats
10/31/2018 • 3 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2016) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
Returns one row for each type of external script request. The external script requests are grouped by the supported
external script language. One row is generated for each registered external script functions. Arbitrary external
script functions are not recorded unless sent by a parent process, such as rxExec .
NOTE
This dynamic management view (DMV) is available only if you have installed and enabled the feature that supports external
script execution. For more information, see R Services in SQL Server 2016 and Machine Learning Services (R, Python) in SQL
Server 2017.
Permissions
Requires VIEW SERVER STATE permission on server.
NOTE
Users who run external scripts must have the additional permission EXECUTE ANY EXTERNAL SCRIPT, however, this DMV can
be used by administrators without this permission.
Remarks
This DMV is provided for internal telemetry, to monitor overall usage of the new external script execution feature
provided in SQL Server. The telemetry service starts when LaunchPad does and increments a disk-based counter
each time a registered external script function is called.
Generally speaking, performance counters are valid only as long as the process that generated them is active.
Therefore, a query on a DMV cannot show detailed data for services that have stopped running. For example, if a
launcher executes external script and yet completes them very quickly, a conventional DMV might not show any
data.
Therefore, the counters tracked by this DMV are kept running, and state for sys.dm_external_script_requests is
preserved by using writes to disk, even if the instance is shut down.
Counter Values
In SQL Server 2016 the only external language supported is R and the external script requests are handled by R
Services (In-Database). In SQL Server 2017, both R and Python are supported external languages and the external
script requests are handled by Machine Learning Services (In-Database).
For R, this DMV tracks the number of R calls that are made on an instance. For example, if rxLinMod is called and
run in parallel, the counter is incremented by 1.
For the R language, the counter values displayed in the counter_name field represent the names of registered
ScaleR functions. The values in the counter_value field represent the cumulative number of instances that the
specific ScaleR function.
For Python, this DMV tracks the number of Python calls that are made on an instance.
The count begins when the feature is installed and enabled on the instance and is cumulative until the file that
maintains state is deleted or overwritten by an administrator. Therefore, it is generally not possible to reset the
values in counter_value. If you want to monitor usage by session, calendar times, or other intervals, we
recommend that you capture the counts to a table.
Registration of external script functions in R
R supports arbitrary scripts, and the R community provides many thousand packages, each with their own
functions and methods. However, this DMV monitors only the ScaleR functions that are installed with SQL Server
R Services.
Registration of these functions is performed when the feature is installed, and registered functions cannot be
added or deleted.
Examples
Viewing the number of R scripts run on the server
The following example displays the cumulative number of external script executions for the R language.
See Also
Dynamic Management Views and Functions (Transact-SQL )
Execution Related Dynamic Management Views and Functions (Transact-SQL ) sys.dm_external_script_requests
sp_execute_external_script
sys.dm_external_script_requests
10/31/2018 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2016) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
Returns a row for each active worker account that is running an external script.
NOTE
This dynamic management view (DMV) is available only if you have installed and enabled the feature that supports external
script execution. For more information, see R Services in SQL Server 2016 and Machine Learning Services (R, Python) in SQL
Server 2017.
Permissions
Requires VIEW SERVER STATE permission on server.
NOTE
Users who run external scripts must have the additional permission EXECUTE ANY EXTERNAL SCRIPT, however, this DMV can
be used by administrators without this permission.
Remarks
This view can be filtered using the script language identifier.
The view also returns the worker account under which the script is being run. For information about worker
accounts used by the external scripts, see the Identities used in processing (SQLRUserGroup) section in Security
overview for the extensibility framework in SQL Server Machine Learning Services.
The GUID that is returned in the external_script_request_id field also represents the file name of the secured
directory where temporary files are stored. Each worker account such as MSSQLSERVER01 represents a single
SQL login or Windows user, and might be used to run multiple script requests. By default, these temporary files
are cleaned up after completion of the requested script.
This DMV monitors only active processes and cannot report on scripts that have already completed. If you need to
track the duration of scripts, we recommend that you add timing information into your script and capture that as
part of script execution.
Examples
Viewing the currently active R scripts for a particular process
The following example displays the number of external script executions being run on the current instance.
SELECT external_script_request_id
, [language]
, degree_of_parallelism
, external_user_name
FROM sys.dm_external_script_requests;
Results
EX TERNAL_SCRIPT_REQUEST_I
D LANGUAGE DEGREE_OF_PARALLELISM EX TERNAL_USER_NAME
183EE6FC-7399-4318- R 1 MSSQLSERVER01
AA2E-7A6C68E435A8
See Also
Dynamic Management Views and Functions (Transact-SQL )
Execution Related Dynamic Management Views and Functions (Transact-SQL )
sys.dm_external_script_execution_stats sp_execute_external_script
Extended Events Dynamic Management Views
10/1/2018 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2012) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
This section contains the following dynamic management objects for SQL Server Extended Events.
sys.dm_xe_session_event_actions (Transact-SQL)
See Also
Dynamic Management Views and Functions (Transact-SQL )
sys.dm_xe_database_sessions (Azure SQL Database)
11/14/2018 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server Azure SQL Database Azure SQL Data Warehouse Parallel Data
Warehouse
Returns information about session events. Events are discrete execution points. Predicates can be applied to events
to stop them from firing if the event does not contain the required information.
||
|-|
|Applies to: Azure SQL Database V12 and any later versions.|
Permissions
Requires VIEW DATABASE STATE permission.
Relationship Cardinalities
As of 2015-07-13, 'sys.dm_xe_objects' is one of these XEvents DMVs that do Not contain '_database' in their name.
Not a typo or error in the following table's right-side column. The name is the same in Microsoft SQL Server and
Azure SQL Database. GeneMi.
FROM TO RELATIONSHIP
See Also
Extended events in Azure SQL Database
Extended Events
sys.dm_xe_database_session_targets (Azure SQL
Database)
10/1/2018 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server Azure SQL Database Azure SQL Data Warehouse Parallel Data
Warehouse
Returns information about session targets.
||
|-|
|Applies to: Azure SQL Database V12 and any future versions.|
Permissions
Requires VIEW DATABASE STATE permission.
Relationship Cardinalities
FROM TO RELATIONSHIP
APPLIES TO: SQL Server Azure SQL Database Azure SQL Data Warehouse Parallel Data
Warehouse
Shows the configuration values for objects that are bound to a session.
||
|-|
|Applies to: Azure SQL Database V12 and any later versions.|
event
target
Permissions
Requires VIEW DATABASE STATE permission.
Relationship Cardinalities
FROM TO RELATIONSHIP
See Also
Extended Events
sys.dm_xe_database_session_events (Azure SQL
Database)
10/1/2018 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server Azure SQL Database Azure SQL Data Warehouse Parallel Data
Warehouse
Returns information about session events. Events are discrete execution points. Predicates can be applied to events
to stop them from firing if the event does not contain the required information.
||
|-|
|Applies to: Azure SQL Database V12 and any later versions.|
Permissions
Requires VIEW DATABASE STATE permission.
Relationship Cardinalities
FROM TO RELATIONSHIP
APPLIES TO: SQL Server Azure SQL Database Azure SQL Data Warehouse Parallel Data
Warehouse
Returns information about event session actions. Actions are executed when events are fired. This management
view aggregates statistics about the number of times an action has run, and the total run time of the action.
||
|-|
|Applies to: Azure SQL Database V12 and any future versions.|
Permissions
Requires VIEW DATABASE STATE permission.
Relationship Cardinalities
FROM TO RELATIONSHIP
APPLIES TO: SQL Server (starting with 2008) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
Returns a mapping of internal numeric keys to human-readable text.
Permissions
Requires VIEW SERVER STATE permission on the server.
Relationship Cardinalities
FROM TO RELATIONSHIP
dm_xe_map_values.name sys.dm_xe_objects.name
See Also
Dynamic Management Views and Functions (Transact-SQL )
sys.dm_xe_object_columns (Transact-SQL)
10/1/2018 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2008) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
Returns the schema information for all the objects.
NOTE
Event objects expose fixed schemas for both read-only and read-write data.
NULL
Permissions
Requires VIEW SERVER STATE permission on the server.
Relationship Cardinalities
FROM TO RELATIONSHIP
sys.dm_xe_object_columns.type_packag sys.dm_xe_objects.package_guid
e_guid
See Also
Dynamic Management Views and Functions (Transact-SQL )
sys.dm_xe_objects (Transact-SQL)
10/1/2018 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2008) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
Returns a row for each object that is exposed by an event package. Objects can be one of the following:
Events. Events indicate points of interest in an execution path. All events contain information about a point
of interest.
Actions. Actions are run synchronously when events fire. An action can append run time data to an event.
Targets. Targets consume events, either synchronously on the thread that fires the event or asynchronously
on a system-provided thread.
Predicates. Predicate sources retrieve values from event sources for use in comparison operations. Predicate
comparisons compare specific data types and return a Boolean value.
Types. Types encapsulate the length and characteristics of the byte collection, which is required in order to
interpret the data.
event
action
target
pred_source
pred_compare
type
Is not nullable.
—
Private. The only object available for
internal use, and that cannot be
accessed via the CREATE/ALTER
EVENT SESSION DDL. Audit events
and targets fall into this category in
addition to a small number of objects
used internally.
===============
Event Capabilities
—
No_block. The event is in a critical
code path that cannot block for any
reason. Events with this capability
may not be added to any event
session that specifies
NO_EVENT_LOSS.
===============
—
Process_whole_buffers. The target
consumes buffers of events at a time,
rather than event by event.
—
Singleton. Only one instance of the
target can exist in a process.
Although multiple event sessions can
reference the same singleton target
there is really only one instance, and
that instance will see each unique
event only once. This is important if
the target is added to multiple
sessions that all collect the same
event.
—
Synchronous. The target is executed
on the thread that is producing the
event, before control is returned to
the calling code line.
Permissions
Requires VIEW SERVER STATE permission on the server.
Relationship Cardinalities
FROM TO RELATIONSHIP
See Also
Dynamic Management Views and Functions (Transact-SQL )
sys.dm_xe_packages (Transact-SQL)
10/1/2018 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2008) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
Lists all the packages registered with the extended events engine.
Permissions
Requires VIEW SERVER STATE permission on the server.
Remarks
The packages registered with the extended events engine expose events, the actions that can be taken at the time
of event firing, and targets for both synchronous and asynchronous processing of event data.
These packages can be dynamically loaded into a process address space. At the time the package is loaded, it
registers all the objects it exposes with the extended events engine.
Relationship Cardinalities
From To Relationship
sys.dm_xe_packages.module_address sys.dm_os_loaded_modules.base_addres Many to one
s
See also
Dynamic Management Views and Functions (Transact-SQL )
sys.dm_xe_session_event_actions (Transact-SQL)
10/1/2018 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2008) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
Returns information about event session actions. Actions are executed when events are fired. This management
view aggregates statistics about the number of times an action has run, and the total run time of the action.
Permissions
Requires VIEW SERVER STATE permission on the server.
Relationship Cardinalities
FROM TO RELATIONSHIP
Change History
UPDATED CONTENT
Updated "Relationship Cardinalities" table with the correct dynamic management view names and column names.
See Also
Dynamic Management Views and Functions (Transact-SQL )
sys.dm_xe_session_events (Transact-SQL)
10/1/2018 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2008) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
Returns information about session events. Events are discrete execution points. Predicates can be applied to events
to stop them from firing if the event does not contain the required information.
Permissions
Requires VIEW SERVER STATE permission on the server.
Relationship Cardinalities
FROM TO RELATIONSHIP
See Also
Dynamic Management Views and Functions (Transact-SQL )
sys.dm_xe_session_object_columns (Transact-SQL)
10/1/2018 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2008) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
Shows the configuration values for objects that are bound to a session.
event
target
Permissions
Requires VIEW SERVER STATE permission on the server.
Relationship Cardinalities
FROM TO RELATIONSHIP
See Also
Dynamic Management Views and Functions (Transact-SQL )
sys.dm_xe_session_targets (Transact-SQL)
10/1/2018 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2008) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
Returns information about session targets.
Permissions
Requires VIEW SERVER STATE permission on the server.
Relationship Cardinalities
FROM TO RELATIONSHIP
Change History
UPDATED CONTENT
Corrected the description for the target_data column to indicate that the value is nullable.
UPDATED CONTENT
See Also
Dynamic Management Views and Functions (Transact-SQL )
sys.dm_xe_sessions (Transact-SQL)
10/1/2018 • 3 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2008) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
Returns information about an active extended events session. This session is a collection of events, actions, and
targets.
Drop event
Dedicated dispatcher
Permissions
Requires VIEW SERVER STATE permission on the server.
Change History
UPDATED CONTENT
Corrected the data type for the name and the blocked_event_fire_time columns.
See Also
Dynamic Management Views and Functions (Transact-SQL )
Filestream and FileTable Dynamic Management Views
(Transact-SQL)
10/1/2018 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2008) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
This section describes the dynamic management views related to the FILESTREAM and FileTable features.
See Also
Filestream
Filetables
Filestream and FileTable Catalog Views (Transact-SQL )
Filestream and FileTable System Stored Procedures (Transact-SQL )
sys.dm_filestream_file_io_handles (Transact-SQL)
10/1/2018 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2008) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
Displays the file handles that the Namespace Owner (NSO ) knows about. Filestream handles that a client got
using OpenSqlFilestream are displayed by this view.
Permissions
Requires VIEW SERVER STATE permission on the server.
See Also
Filestream and FileTable Dynamic Management Views (Transact-SQL )
sys.dm_filestream_file_io_requests (Transact-SQL)
10/1/2018 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2008) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
Displays a list of I/O requests being processed by the Namespace Owner (NSO ) at the given moment.
Is nullable.
Permissions
Requires VIEW SERVER STATE permission on the server.
See Also
Filestream and FileTable Dynamic Management Views (Transact-SQL )
sys.dm_filestream_non_transacted_handles (Transact-
SQL)
10/1/2018 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2008) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
Displays the currently open non-transactional file handles associated with FileTable data.
This view contains one row per open file handle. Because the data in this view corresponds to the live internal state
of the server, the data is constantly changing as handles are opened and closed. This view does not contain
historical information.
For more information, see Manage FileTables.
See Also
Manage FileTables
Full-Text and Semantic Search Dynamic
Management Views - Functions
11/14/2018 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2008) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
This section contains the following dynamic management views and functions that are related to full-text search
and semantic search.
See Also
Dynamic Management Views and Functions (Transact-SQL )
System Views (Transact-SQL )
sys.dm_fts_active_catalogs (Transact-SQL)
10/1/2018 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2008) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
Returns information on the full-text catalogs that have some population activity in progress on the server.
NOTE
The following columns will be removed in a future version of Microsoft SQL Server: is_paused, previous_status,
previous_status_description, row_count_in_thousands, status, status_description, and worker_count. Avoid using these
columns in new development work, and plan to modify applications that currently use any of them.
0 = Initializing
1 = Ready
2 = Paused
3 = Temporary error
4 = Remount needed
5 = Shutdown
8 = Catalog is corrupt
0 = Initializing
1 = Ready
2 = Paused
3 = Temporary error
4 = Remount needed
5 = Shutdown
8 = Catalog is corrupt
Remarks
The is_importing column was new in SQL Server 2008.
Permissions
On SQL Server, requires VIEW SERVER STATE permission.
On SQL Database, requires the VIEW DATABASE STATE permission in the database.
Physical Joins
Relationship Cardinalities
FROM TO RELATIONSHIP
Examples
The following example returns information about the active full-text catalogs on the current database.
See Also
Full-Text Search and Semantic Search Dynamic Management Views and Functions (Transact-SQL )
sys.dm_fts_fdhosts (Transact-SQL)
10/1/2018 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2008) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
Returns information on the current activity of the filter daemon host or hosts on the server instance.
Single thread
Multi-thread
Huge document
Permissions
On SQL Server, requires VIEW SERVER STATE permission.
On SQL Database, requires the VIEW DATABASE STATE permission in the database.
Examples
The following example returns the name of the filter daemon host and the maximum number of threads in it. It
also monitors how many batches are currently being processed in the filter daemon. This information can be used
to diagnose performance.
See Also
Full-Text Search and Semantic Search Dynamic Management Views and Functions (Transact-SQL )
Full-Text Search
sys.dm_fts_index_keywords (Transact-SQL)
10/1/2018 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2008) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
Returns information about the content of a full-text index for the specified table.
sys.dm_fts_index_keywords is a dynamic management function.
NOTE
To view lower-level full-text index information, use the sys.dm_fts_index_keywords_by_document dynamic management
function at the document level.
Syntax
sys.dm_fts_index_keywords( DB_ID('database_name'), OBJECT_ID('table_name') )
Arguments
db_id('database_name')
A call to the DB_ID () function. This function accepts a database name and returns the database ID, which
sys.dm_fts_index_keywords uses to find the specified database. If database_name is omitted, the current
database ID is returned.
object_id('table_name')
A call to the OBJECT_ID () function. This function accepts a table name and returns the table ID of the table
containing the full-text index to inspect.
Table Returned
COLUMN NAME DATA TYPE DESCRIPTION
Remarks
The information returned by sys.dm_fts_index_keywords is useful for finding out the following, among other
things:
Whether a keyword is part of the full-text index.
How many documents or rows contain a given keyword.
The most common keyword in the full-text index:
document_count of each keyword_value compared to the total document_count, the document
count of 0xFF.
Typically, common keywords are likely to be appropriate to declare as stopwords.
NOTE
The document_count returned by sys.dm_fts_index_keywords may be less accurate for a specific document than the
count returned by sys.dm_fts_index_keywords_by_document or a CONTAINS query. This potential inaccuracy is
estimated to be less than 1%. This inaccuracy can occur because a document_id may be counted twice when it continues
across more than one row in the index fragment, or when it appears more than once in the same row. To obtain a more
accurate count for a specific document, use sys.dm_fts_index_keywords_by_document or a CONTAINS query.
Permissions
Requires membership in the sysadmin fixed server role.
Examples
A. Displaying high-level full-text index content
The following example displays information about the high-level content of the full-text index in the
HumanResources.JobCandidate table.
See Also
Full-Text Search and Semantic Search Dynamic Management Views and Functions (Transact-SQL )
Full-Text Search
sys.dm_fts_index_keywords_by_document (Transact-SQL )
sys.dm_fts_index_keywords_by_document (Transact-
SQL)
10/1/2018 • 3 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2008) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
Returns information about the document-level content of a full-text index associated with the specified table.
sys.dm_fts_index_keywords_by_document is a dynamic management function.
To view higher-level full-text index information
sys.dm_fts_index_keywords (Transact-SQL )
To view information about property-level content related to a document property
sys.dm_fts_index_keywords_by_property (Transact-SQL )
Syntax
sys.dm_fts_index_keywords_by_document
(
DB_ID('database_name'), OBJECT_ID('table_name')
)
Arguments
db_id('database_name')
A call to the DB_ID () function. This function accepts a database name and returns the database ID, which
sys.dm_fts_index_keywords_by_document uses to find the specified database. If database_name is omitted, the
current database ID is returned.
object_id('table_name')
A call to the OBJECT_ID () function. This function accepts a table name and returns the table ID of the table
containing the full-text index to inspect.
Table Returned
COLUMN DATA TYPE DESCRIPTION
Remarks
The information returned by sys.dm_fts_index_keywords_by_document is useful for finding out the following,
among other things:
The total number of keywords that a full-text index contains.
Whether a keyword is part of a given document or row.
How many times a keyword appears in the whole full-text index; that is:
(SUM (occurrence_count) WHERE keyword=keyword_value )
How many times a keyword appears in a given document or row.
How many keywords a given document or row contains.
Also, you can also use the information provided by sys.dm_fts_index_keywords_by_document to retrieve all
the keywords belonging to a given document or row.
When the full-text key column is an integer data type, as recommended, the document_id maps directly to
the full-text key value in the base table.
In contrast, when the full-text key column uses a non-integer data type, document_id does not represent
the full-text key in the base table. In this case, to identify the row in the base table that is returned by
dm_fts_index_keywords_by_document, you need to join this view with the results returned by
sp_fulltext_keymappings. Before you can join them, you must store the output of the stored procedure in a
temp table. Then you can join the document_id column of dm_fts_index_keywords_by_document with the
DocId column that is returned by this stored procedure. Note that a timestamp column cannot receive
values at insert time, because they are auto-generated by SQL Server. Therefore, the timestamp column
must be converted to varbinary(8) columns. The following example shows these steps. In this example,
table_id is the ID of your table, database_name is the name of your database, and table_name is the name
of your table.
USE database_name;
GO
CREATE TABLE #MyTempTable
(
docid INT PRIMARY KEY ,
[key] INT NOT NULL
);
DECLARE @db_id int = db_id(N'database_name');
DECLARE @table_id int = OBJECT_ID(N'table_name');
INSERT INTO #MyTempTable EXEC sp_fulltext_keymappings @table_id;
SELECT * FROM sys.dm_fts_index_keywords_by_document
( @db_id, @table_id ) kbd
INNER JOIN #MyTempTable tt ON tt.[docid]=kbd.document_id;
GO
Permissions
Requires SELECT permission on the columns covered by the full-text index and CREATE FULLTEXT CATALOG
permissions.
Examples
A. Displaying full-text index content at the document level
The following example displays the content of the full-text index at the document level in the
HumanResources.JobCandidate table of the AdventureWorks2012 sample database.
NOTE
You can create this index by executing the example provided for the HumanResources.JobCandidate table in CREATE
FULLTEXT INDEX (Transact-SQL).
See Also
Full-Text Search and Semantic Search Dynamic Management Views and Functions (Transact-SQL )
Full-Text Search
sys.dm_fts_index_keywords (Transact-SQL )
sys.dm_fts_index_keywords_by_property (Transact-SQL )
sp_fulltext_keymappings (Transact-SQL )
Improve the Performance of Full-Text Indexes
sys.dm_fts_index_keywords_by_property (Transact-
SQL)
10/1/2018 • 4 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2012) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
Returns all property-related content in the full-text index of a given table. This includes all data that belongs to any
property registered by the search property list associated with that full-text index.
sys.dm_fts_index_keywords_by_property is a dynamic management function that enables you to see what
registered properties were emitted by IFilters at index time, as well as the exact content of every property in each
indexed document.
To view all document-level content (including property-related content)
sys.dm_fts_index_keywords_by_document (Transact-SQL )
To view higher-level full-text index information
sys.dm_fts_index_keywords (Transact-SQL )
NOTE
For information about search property lists, see Search Document Properties with Search Property Lists.
Syntax
sys.dm_fts_index_keywords_by_property
(
DB_ID('database_name'),
OBJECT_ID('table_name')
)
Arguments
db_id('database_name')
A call to the DB_ID () function. This function accepts a database name and returns the database ID, which
sys.dm_fts_index_keywords_by_property uses to find the specified database. If database_name is omitted, the
current database ID is returned.
object_id('table_name')
A call to the OBJECT_ID () function. This function accepts a table name and returns the table ID of the table
containing the full-text index to inspect.
Table Returned
COLUMN DATA TYPE DESCRIPTION
Remarks
This dynamic management view can answer questions such as the following:
What content is stored on a given property for a given DocID?
How common is a given property among the indexed documents?
What documents actually contain a given property? This is useful if querying on a given search property
does not return a document that you expected to find.
When the full-text key column is an integer data type, as recommended, the document_id maps directly to
the full-text key value in the base table.
In contrast, when the full-text key column uses a non-integer data type, document_id does not represent the
full-text key in the base table. In this case, to identify the row in the base table that is returned by
dm_fts_index_keywords_by_property, you need to join this view with the results returned by
sp_fulltext_keymappings. Before you can join them, you must store the output of the stored procedure in a
temp table. Then you can join the document_id column of dm_fts_index_keywords_by_property with the
DocId column that is returned by this stored procedure. Note that a timestamp column cannot receive
values at insert time, because they are auto-generated by SQL Server. Therefore, the timestamp column
must be converted to varbinary(8) columns. The following example shows these steps. In this example,
table_id is the ID of your table, database_name is the name of your database, and table_name is the name
of your table.
USE database_name;
GO
CREATE TABLE #MyTempTable
(
docid INT PRIMARY KEY ,
[key] INT NOT NULL
);
DECLARE @db_id int = db_id(N'database_name');
DECLARE @table_id int = OBJECT_ID(N'table_name');
INSERT INTO #MyTempTable EXEC sp_fulltext_keymappings @table_id;
SELECT * FROM sys.dm_fts_index_keywords_by_property
( @db_id, @table_id ) kbd
INNER JOIN #MyTempTable tt ON tt.[docid]=kbd.document_id;
GO
Permissions
Requires SELECT permission on the columns covered by the full-text index and CREATE FULLTEXT CATALOG
permissions.
Examples
The following example returns keywords from the Author property in the full-text index of the
Production.Document table of the AdventureWorks sample database. The example uses the alias KWBPOP for the
table returned by sys.dm_fts_index_keywords_by_property. The example uses inner joins to combine columns
from sys.registered_search_properties and sys.fulltext_indexes.
-- Once the full-text index is configured to support property searching
-- on the Author property, return any keywords indexed for this property.
USE AdventureWorks2012;
GO
SELECT KWBPOP.* FROM
sys.dm_fts_index_keywords_by_property( DB_ID(),
object_id('Production.Document') ) AS KWBPOP
INNER JOIN
sys.registered_search_properties AS RSP ON(
(KWBPOP.property_id = RSP.property_id)
AND (RSP.property_name = 'Author') )
INNER JOIN
sys.fulltext_indexes AS FTI ON(
(FTI.[object_id] = object_id('Production.Document'))
AND (RSP.property_list_id = FTI.property_list_id) );
GO
See Also
Full-Text Search
Improve the Performance of Full-Text Indexes
sp_fulltext_keymappings (Transact-SQL )
sys.dm_fts_index_keywords_by_document (Transact-SQL )
sys.dm_fts_index_keywords (Transact-SQL )
sys.registered_search_properties (Transact-SQL )
sys.registered_search_property_lists (Transact-SQL )
Search Document Properties with Search Property Lists
sys.dm_fts_index_keywords_position_by_document
(Transact-SQL)
10/1/2018 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2012) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
Returns keyword positional information in the indexed documents.
Syntax
sys.dm_fts_index_keywords_position_by_document
(
DB_ID('database_name'),
OBJECT_ID('table_name')
)
Arguments
db_id('database_name')
A call to the DB_ID () function. This function accepts a database name and returns the database ID, which
sys.dm_fts_index_keywords_position_by_document uses to find the specified database.
object_id('table_name')
A call to the OBJECT_ID () function. This function accepts a table name and returns the table ID of the table
containing the full-text index to inspect.
Table Returned
COLUMN DATA TYPE DESCRIPTION
Remarks
Use the DMV to identify the location of indexed words in indexed documents. This DMV can be used to
troubleshoot issues when sys.dm_fts_index_keywords_by_document indicates the words are in the full-text
index, but when you run a query using those words, the document is not returned.
Permissions
Requires SELECT permission on the columns covered by the full-text index and CREATE FULLTEXT CATALOG
permissions.
Examples
The following example returns keywords from the full-text index of the Production.Document table of the
AdventureWorks sample database.
USE AdventureWorks2012;
GO
You can add a predicate on the other columns_id as in the following example query, to further isolate the locations.
See Also
Full-Text Search
Improve the Performance of Full-Text Indexes
Full-Text Search and Semantic Search Functions (Transact-SQL )
Full-Text Search and Semantic Search Dynamic Management Views and Functions (Transact-SQL )
Full-Text Search and Semantic Search Stored Procedures (Transact-SQL )
Search Document Properties with Search Property Lists
sys.dm_fts_index_keywords_by_document (Transact-SQL )
sys.dm_fts_index_population (Transact-SQL)
10/1/2018 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2008) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
Returns information about the full-text index and semantic key phrase populations currently in progress in SQL
Server.
1 = Full population
2 = Incremental timestamp-based
population
3 = Starting
5 = Processing normally
11 = Population aborted
Remarks
When statistical semantic indexing is enabled in addition to full-text indexing, the semantic extraction and
population of key phrases, and the extraction of document similarity data, occur simultaneously with full-text
indexing. The population of the document similarity index occurs later in a second phase. For more information,
see Manage and Monitor Semantic Search.
Permissions
On SQL Server, requires VIEW SERVER STATE permission.
On SQL Database, requires the VIEW DATABASE STATE permission in the database.
Physical Joins
Relationship Cardinalities
FROM TO RELATIONSHIP
See Also
Dynamic Management Views and Functions (Transact-SQL )
Full-Text Search and Semantic Search Dynamic Management Views and Functions (Transact-SQL )
sys.dm_fts_memory_buffers (Transact-SQL)
10/1/2018 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2008) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
Returns information about memory buffers belonging to a specific memory pool that are used as part of a full-text
crawl or a full-text crawl range.
NOTE
The following column will be removed in a future release of Microsoft SQL Server: row_count. Avoid using this column in
new development work, and plan to modify applications that currently use it.
0 = Small buffers
1 = Large buffers
0 = Free
1 = Busy
Permissions
On SQL Server, requires VIEW SERVER STATE permission.
On SQL Database, requires the VIEW DATABASE STATE permission in the database.
Physical Joins
Relationship Cardinalities
FROM TO RELATIONSHIP
See Also
Dynamic Management Views and Functions (Transact-SQL )
Full-Text Search and Semantic Search Dynamic Management Views and Functions (Transact-SQL )
sys.dm_fts_memory_pools (Transact-SQL)
10/1/2018 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2008) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
Returns information about the shared memory pools available to the Full-Text Gatherer component for a full-text
crawl or a full-text crawl range.
0 = Small buffers
1 = Large buffers
Permissions
On SQL Server, requires VIEW SERVER STATE permission.
On SQL Database, requires the VIEW DATABASE STATE permission in the database.
Physical Joins
Relationship Cardinalities
FROM TO RELATIONSHIP
Examples
The following example returns the total shared memory owned by the Microsoft Full-Text Gatherer component of
the SQL Server process:
SELECT SUM(buffer_size * buffer_count) AS "total memory"
FROM sys.dm_fts_memory_pools;
See Also
Full-Text Search and Semantic Search Dynamic Management Views and Functions (Transact-SQL )
sys.dm_fts_outstanding_batches (Transact-SQL)
10/1/2018 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2008) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
Returns information about each full-text indexing batch.
0 = No
1 = Yes
0 = No retry
NO RETRY
Permissions
On SQL Server, requires VIEW SERVER STATE permission.
On SQL Database, requires the VIEW DATABASE STATE permission in the database.
Examples
The following example finds out how many batches are currently being processed for each table in the server
instance.
See Also
Full-Text Search and Semantic Search Dynamic Management Views and Functions (Transact-SQL )
Full-Text Search
sys.dm_fts_parser (Transact-SQL)
10/1/2018 • 6 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2008) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
Returns the final tokenization result after applying a given word breaker, thesaurus, and stoplist combination to a
query string input. The tokenization result is equivalent to the output of the Full-Text Engine for the specified query
string.
sys.dm_fts_parser is a dynamic management function.
Syntax
sys.dm_fts_parser('query_string', lcid, stoplist_id, accent_sensitivity)
Arguments
query_string
The query that you want to parse. query_string can be a string chain that CONTAINS syntax support. For example,
you can include inflectional forms, a thesaurus, and logical operators.
lcid
Locale identifier (LCID ) of the word breaker to be used for parsing query_string.
stoplist_id
ID of the stoplist, if any, to be used by the word breaker identified by lcid. stoplist_id is int. If you specify 'NULL', no
stoplist is used. If you specify 0, the system STOPLIST is used.
A stoplist ID is unique within a database. To obtain the stoplist ID for a full-text index on a given table use the
sys.fulltext_indexes catalog view.
accent_sensitivity
Boolean value that controls whether full-text search is sensitive or insensitive to diacritics. accent_sensitivity is bit,
with one of the following values:
0 Insensitive
1 Sensitive
NOTE
To view the current setting of this value for a full-text catalog, run the following Transact-SQL statement:
SELECT fulltextcatalogproperty(' catalog_name ', 'AccentSensitivity'); .
Table Returned
COLUMN NAME DATA TYPE DESCRIPTION
1: Server
2: DB
3: DB
1 for multi
1 for million
2 for multimillion
COLUMN NAME DATA TYPE DESCRIPTION
1 for SQL
2 for Server
3 for query
4 for processor
Exact match
Noise word
End of Sentence
End of paragraph
End of Chapter
2=Inflectional expansion
4=Thesaurus expansion/replacement
<expansion>
<sub>run</sub>
<sub>jog</sub>
</expansion>
Remarks
sys.dm_fts_parser supports the syntax and features of full-text predicates, such as CONTAINS and FREETEXT,
and functions, such as CONTAINSTABLE and FREETEXTTABLE.
The results tell you what terms are being passed to the full-text index.
To understand how the thesaurus expands or replaces all or part of the input
You can also specify:
The results of this query show how the word breaker and thesaurus interact for the query term. you can see
the expansion or replacements from the thesaurus and identify the resulting query that is actually being
issued against the full-text index.
Note that if the user issues:
Permissions
Requires membership in the sysadmin fixed server role and access rights to the specified stoplist.
Examples
A. Displaying the output of a given word breaker for a keyword or phrase
The following example returns the output from using the English word breaker, whose LCID is 1033, and no
stoplist on the following query string:
The Microsoft business analysis
SELECT * FROM sys.dm_fts_parser (' "The Microsoft business analysis" ', 1033, 0, 0);
B. Displaying the output of a given word breaker in the context of stoplist filtering
The following example returns the output from using the English word breaker, whose LCID is 1033, and an
English stoplist, whose ID is 77, on the following query string:
"The Microsoft business analysis" OR "MS revenue"
SELECT * FROM sys.dm_fts_parser (' "The Microsoft business analysis" OR " MS revenue" ', 1033, 77, 0);
The example specifies the LCID for the French language, 1036 , and the ID of a user-defined stoplist, 5 . Accent
sensitivity is enabled.
See Also
Full-Text Search and Semantic Search Dynamic Management Views and Functions (Transact-SQL )
Full-Text Search
Configure and Manage Word Breakers and Stemmers for Search
Configure and Manage Thesaurus Files for Full-Text Search
Configure and Manage Stopwords and Stoplists for Full-Text Search
Query with Full-Text Search
Query with Full-Text Search
Securables
sys.dm_fts_population_ranges (Transact-SQL)
10/1/2018 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2008) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
Returns information about the specific ranges related to a full-text index population currently in progress.
Permissions
On SQL Server, requires VIEW SERVER STATE permission.
On SQL Database, requires the VIEW DATABASE STATE permission in the database.
Physical Joins
Relationship Cardinalities
FROM TO RELATIONSHIP
See Also
Full-Text Search and Semantic Search Dynamic Management Views and Functions (Transact-SQL )
sys.dm_fts_semantic_similarity_population (Transact-
SQL)
10/1/2018 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2008) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
Returns one row of status information about the population of the document similarity index for each similarity
index in each table that has an associated semantic index.
The population step follows the extraction step. For status information about the similarity extraction step, see
sys.dm_fts_index_population (Transact-SQL ).
3 = Starting
5 = Processing normally
11 = Population aborted
General Remarks
For more information, see Manage and Monitor Semantic Search.
Metadata
For more information about the status of semantic indexing, query sys.dm_fts_index_population (Transact-SQL ).
Security
Permissions
Requires VIEW SERVER STATE permission on the server.
Examples
The following example shows how to query the status of document similarity index populations for all tables that
have an associated semantic index:
See Also
Manage and Monitor Semantic Search
Geo-Replication Dynamic Management Views and
Functions (Azure SQL Database)
10/1/2018 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2016) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
This section contains the following catalog views that display information about geo-replication.
APPLIES TO: SQL Server Azure SQL Database Azure SQL Data Warehouse Parallel Data
Warehouse
Contains a row for each replication link between primary and secondary databases in a geo-replication
partnership. This view resides in the logical master database.
SEEDING
CATCH_UP
SECONDARY
All
Read-Only
Permissions
This view is only available in the master database to the server-level principal login.
Example
Show all databases with geo-replication links.
SELECT
database_id
, start_date
, partner_server
, partner_database
, replication_state
, role_desc
, secondary_allow_connections_desc
FROM sys.geo_replication_links;
See Also
ALTER DATABASE (Azure SQL Database)
sys.dm_geo_replication_link_status (Azure SQL Database)
sys.dm_operation_status (Azure SQL Database)
sys.dm_geo_replication_link_status (Azure SQL
Database)
10/1/2018 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server Azure SQL Database Azure SQL Data Warehouse Parallel Data
Warehouse
Contains a row for each replication link between primary and secondary databases in a geo-replication
partnership. This includes both primary and secondary databases. If more than one continuous replication link
exists for a given primary database, this table contains a row for each of the relationships. The view is created in
all databases, including the logical master. However, querying this view in the logical master returns an empty set.
SEEDING
CATCH_UP
SECONDARY
secondary_allow_connections_desc nvarchar(256) No
All
COLUMN NAME DATA TYPE DESCRIPTION
NOTE
If the replication relationship is terminated by removing the secondary database (section 4.2), the row for that database in
the sys.dm_geo_replication_link_status view disappears.
Permissions
Any account with view_database_state permission can query sys.dm_geo_replication_link_status.
Example
Show replication lags and last replication time of my secondary databases.
SELECT
link_guid
, partner_server
, last_replication
, replication_lag_sec
FROM sys.dm_geo_replication_link_status;
See Also
ALTER DATABASE (Azure SQL Database)
sys.geo_replication_links (Azure SQL Database)
sys.dm_operation_status (Azure SQL Database)
sys.dm_continuous_copy_status (Azure SQL
Database)
11/14/2018 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server Azure SQL Database Azure SQL Data Warehouse Parallel Data
Warehouse
Returns a row for each user database (V11) that is currently engaged in a Geo-replication continuous-copy
relationship. If more than one continuous copy relationship is initiated for a given primary database this table
contains one row for each active secondary database.
If you are using SQL Database V12 you should use sys.dm_geo_replication_link_status (because
sys.dm_continuous_copy_status only applies to V11).
SEEDING
CATCH_UP
RE_SEEDING
SUSPENDED
0 = Interlink is disconnected.
Permissions
To retrieve data, requires membership in the db_owner database role. The dbo user, members of the dbmanager
database role, and the sa login can all query this view as well.
Remarks
The sys.dm_continuous_copy_status view is created in the resource database and is visible in all databases,
including the logical master. However, querying this view in the logical master returns an empty set.
If the continuous-copy relationship is terminated on a database, the row for that database in the
sys.dm_continuous_copy_status view disappears.
Like the sys.dm_database_copies view, sys.dm_continuous_copy_status reflects the state of the continuous
copy relationship in which the database is either a primary or active secondary database. Unlike
sys.dm_database_copies, sys.dm_continuous_copy_status contains several columns that provide details about
operations and performance. These columns include last_replication, and replication_lag_sec..
See Also
sys.dm_database_copies (Azure SQL Database)
Active Geo-Replication Stored Procedures (Transact-SQL )
Index Related Dynamic Management Views and
Functions (Transact-SQL)
11/14/2018 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2012) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
This section contains the following dynamic management objects.
See Also
Dynamic Management Views and Functions (Transact-SQL )
Dynamic Management Views and Functions (Transact-SQL )
System Views (Transact-SQL )
sys.dm_column_store_object_pool (Transact-SQL)
10/1/2018 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2016) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
Returns counts of different types of object memory pool usage for columnstore index objects.
2=
COLUMN_SEGMENT_PRIMARY_DICTIO
NARY
3=
COLUMN_SEGMENT_SECONDARY_DIC
TIONARY
4=
COLUMN_SEGMENT_BULKINSERT_DICT
IONARY
5=
COLUMN_SEGMENT_DELETE_BITMAP
COLUMN NAME DATA TYPE DESCRIPTION
COLUMN_SEGMENT_PRIMARY_DICTIO
NARY – A global dictionary that
contains lookup information for all of
the column segments in the table.
COLUMN_SEGMENT_SECONDARY_DIC
TIONARY - A local dictionary associated
with one column.
COLUMN_SEGMENT_BULKINSERT_DICT
IONARY – Another representation of
the global dictionary. This provides an
inverse look up of value to
dictionary_id. Used for creating
compressed segments as part of Tuple
Mover or Bulk Load.
COLUMN_SEGMENT_DELETE_BITMAP –
A bitmap that tracks segment deletes.
There is one delete bitmap per partition.
Permissions
On SQL Server, requires VIEW SERVER STATE permission.
On SQL Database, requires the VIEW DATABASE STATE permission in the database.
See Also
Index Related Dynamic Management Views and Functions (Transact-SQL )
sys.dm_db_index_physical_stats (Transact-SQL )
sys.dm_db_index_operational_stats (Transact-SQL )
sys.indexes (Transact-SQL )
sys.objects (Transact-SQL )
Monitor and Tune for Performance
sys.dm_db_column_store_row_group_operational_stats
(Transact-SQL)
10/1/2018 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2016) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
Returns current row -level I/O, locking, and access method activity for compressed rowgroups in a columnstore
index. Use sys.dm_db_column_store_row_group_operational_stats to track the length of time a user query
must wait to read or write to a compressed rowgroup or partition of a columnstore index, and identify rowgroups
that are encountering significant I/O activity or hot spots.
In-memory columnstore indexes do not appear in this DMV.
See Also
Dynamic Management Views and Functions (Transact-SQL )
Index Related Dynamic Management Views and Functions (Transact-SQL )
Monitor and Tune for Performance
sys.dm_db_index_physical_stats (Transact-SQL )
sys.dm_db_index_usage_stats (Transact-SQL )
sys.dm_os_latch_stats (Transact-SQL )
sys.dm_db_partition_stats (Transact-SQL )
sys.allocation_units (Transact-SQL )
sys.indexes (Transact-SQL )
sys.dm_db_column_store_row_group_physical_stats
(Transact-SQL)
10/1/2018 • 5 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2016) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
Provides current rowgroup-level information about all of the columnstore indexes in the current database.
This extends the catalog view sys.column_store_row_groups (Transact-SQL ).
0 = INVISIBLE
1 = OPEN
2 = CLOSED
3 = COMPRESSED
4 = TOMBSTONE
0–
UNKNOWN_UPGRADED_FROM_PREVI
OUS_VERSION
1 - NO_TRIM
2 - BULKLOAD
3 – REORG
4 – DICTIONARY_SIZE
5 – MEMORY_LIMITATION
6 – RESIDUAL_ROW_GROUP
7 - STATS_MISMATCH
8 - SPILLOVER
COLUMN NAME DATA TYPE DESCRIPTION
0–
UNKNOWN_UPGRADED_FROM_PREVI
OUS_VERSION: Occurred when
upgrading from the previous version of
SQL Server.
6 – RESIDUAL_ROW_GROUP: Closed as
part of last row group with rows < 1
million during index build operation
1- NOT_APPLICABLE
2 – INDEX_BUILD
3 – TUPLE_MOVER
4 – REORG_NORMAL
5 – REORG_FORCED
6 - BULKLOAD
7 - MERGE
0 = No
1 = Yes
Results
Returns one row for each rowgroup in the current database.
Permissions
Requires these permissions:
CONTROL permission on the table.
VIEW DATABASE STATE permission on the database.
Examples
A. Calculate fragmentaton to decide when to reorganize or rebuild a columnstore index.
For columnstore indexes, the percent of deleted rows is a good measure for the fragmentation in a rowgroup.
When the fragmentation is 20% or more we recommend removing the deleted rows. For examples, see
Columnstore Indexes Defragmentation.
This example joins sys.dm_db_column_store_row_group_physical_stats with other system tables and then
calculates the Fragmentation column as an estimate of the efficiency of each row group in the current database. To
find information on a single table remove the comment hyphens in front of the WHERE clause and provide a table
name.
SELECT i.object_id,
object_name(i.object_id) AS TableName,
i.name AS IndexName,
i.index_id,
i.type_desc,
CSRowGroups.*,
100*(ISNULL(deleted_rows,0))/total_rows AS 'Fragmentation'
FROM sys.indexes AS i
JOIN sys.dm_db_column_store_row_group_physical_stats AS CSRowGroups
ON i.object_id = CSRowGroups.object_id AND i.index_id = CSRowGroups.index_id
-- WHERE object_name(i.object_id) = 'table_name'
ORDER BY object_name(i.object_id), i.name, row_group_id;
See Also
Object Catalog Views (Transact-SQL )
Catalog Views (Transact-SQL )
Querying the SQL Server System Catalog FAQ
sys.columns (Transact-SQL )
sys.all_columns (Transact-SQL )
sys.computed_columns (Transact-SQL )
Columnstore Indexes Guide
sys.column_store_dictionaries (Transact-SQL )
sys.column_store_segments (Transact-SQL )
sys.dm_db_index_operational_stats (Transact-SQL)
11/14/2018 • 10 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2008) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
Returns current lower-level I/O, locking, latching, and access method activity for each partition of a table or index
in the database.
Memory-optimized indexes do not appear in this DMV.
NOTE
sys.dm_db_index_operational_stats does not return information about memory-optimized indexes. For information about
memory-optimized index use, see sys.dm_db_xtp_index_stats (Transact-SQL).
Syntax
sys.dm_db_index_operational_stats (
{ database_id | NULL | 0 | DEFAULT }
, { object_id | NULL | 0 | DEFAULT }
, { index_id | 0 | NULL | -1 | DEFAULT }
, { partition_number | NULL | 0 | DEFAULT }
)
Arguments
database_id | NULL | 0 | DEFAULT
ID of the database. database_id is smallint. Valid inputs are the ID number of a database, NULL, 0, or DEFAULT.
The default is 0. NULL, 0, and DEFAULT are equivalent values in this context.
Specify NULL to return information for all databases in the instance of SQL Server. If you specify NULL for
database_id, you must also specify NULL for object_id, index_id, and partition_number.
The built-in function DB_ID can be specified.
object_id | NULL | 0 | DEFAULT
Object ID of the table or view the index is on. object_id is int.
Valid inputs are the ID number of a table and view, NULL, 0, or DEFAULT. The default is 0. NULL, 0, and DEFAULT
are equivalent values in this context.
Specify NULL to return cached information for all tables and views in the specified database. If you specify NULL
for object_id, you must also specify NULL for index_id and partition_number.
index_id | 0 | NULL | -1 | DEFAULT
ID of the index. index_id is int. Valid inputs are the ID number of an index, 0 if object_id is a heap, NULL, -1, or
DEFAULT. The default is -1, NULL, -1, and DEFAULT are equivalent values in this context.
Specify NULL to return cached information for all indexes for a base table or view. If you specify NULL for
index_id, you must also specify NULL for partition_number.
partition_number | NULL | 0 | DEFAULT
Partition number in the object. partition_number is int. Valid inputs are the partion_number of an index or heap,
NULL, 0, or DEFAULT. The default is 0. NULL, 0, and DEFAULT are equivalent values in this context.
Specify NULL to return cached information for all partitions of the index or heap.
partition_number is 1-based. A nonpartitioned index or heap has partition_number set to 1.
Table Returned
COLUMN NAME DATA TYPE DESCRIPTION
0 = Heap
0 = Heap or columnstore
0 = Heap or columnstore
0 = Heap or columnstore
0 = Heap or columnstore
0 = Heap or columnstore
0 = Indexes
COLUMN NAME DATA TYPE DESCRIPTION
0 = Nonclustered index
0 = Nonclustered index
Remarks
This dynamic management object does not accept correlated parameters from CROSS APPLY and OUTER
APPLY.
You can use sys.dm_db_index_operational_stats to track the length of time that users must wait to read or write
to a table, index, or partition, and identify the tables or indexes that are encountering significant I/O activity or hot
spots.
Use the following columns to identify areas of contention.
To analyze a common access pattern to the table or index partition, use these columns:
leaf_insert_count
leaf_delete_count
leaf_update_count
leaf_ghost_count
range_scan_count
singleton_lookup_count
To identify latching and locking contention, use these columns:
page_latch_wait_count and page_latch_wait_in_ms
These columns indicate whether there is latch contention on the index or heap, and the significance of the
contention.
row_lock_count and page_lock_count
These columns indicate how many times the Database Engine tried to acquire row and page locks.
row_lock_wait_in_ms and page_lock_wait_in_ms
These columns indicate whether there is lock contention on the index or heap, and the significance of the
contention.
To analyze statistics of physical I/Os on an index or heap partition
page_io_latch_wait_count and page_io_latch_wait_in_ms
These columns indicate whether physical I/Os were issued to bring the index or heap pages into memory
and how many I/Os were issued.
Column Remarks
The values in lob_orphan_create_count and lob_orphan_insert_count should always be equal.
The value in the columns lob_fetch_in_pages and lob_fetch_in_bytes can be greater than zero for nonclustered
indexes that contain one or more LOB columns as included columns. For more information, see Create Indexes
with Included Columns. Similarly, the value in the columns row_overflow_fetch_in_pages and
row_overflow_fetch_in_bytes can be greater than 0 for nonclustered indexes if the index contains columns that
can be pushed off-row.
Permissions
Requires the following permissions:
CONTROL permission on the specified object within the database
VIEW DATABASE STATE permission to return information about all objects within the specified database,
by using the object wildcard @object_id = NULL
VIEW SERVER STATE permission to return information about all databases, by using the database wildcard
@database_id = NULL
Granting VIEW DATABASE STATE allows all objects in the database to be returned, regardless of any
CONTROL permissions denied on specific objects.
Denying VIEW DATABASE STATE disallows all objects in the database to be returned, regardless of any
CONTROL permissions granted on specific objects. Also, when the database wildcard
@database_id=NULL is specified, the database is omitted.
For more information, see Dynamic Management Views and Functions (Transact-SQL ).
Examples
A. Returning information for a specified table
The following example returns information for all indexes and partitions of the Person.Address table in the
AdventureWorks2012 database. Executing this query requires, at a minimum, CONTROL permission on
Person.Address table.
IMPORTANT
When you are using the Transact-SQL functions DB_ID and OBJECT_ID to return a parameter value, always ensure that a
valid ID is returned. If the database or object name cannot be found, such as when they do not exist or are spelled
incorrectly, both functions will return NULL. The sys.dm_db_index_operational_stats function interprets NULL as a
wildcard value that specifies all databases or all objects. Because this can be an unintentional operation, the examples in this
section demonstrate the safe way to determine database and object IDs.
See Also
Dynamic Management Views and Functions (Transact-SQL )
Index Related Dynamic Management Views and Functions (Transact-SQL )
Monitor and Tune for Performance
sys.dm_db_index_physical_stats (Transact-SQL )
sys.dm_db_index_usage_stats (Transact-SQL )
sys.dm_os_latch_stats (Transact-SQL )
sys.dm_db_partition_stats (Transact-SQL )
sys.allocation_units (Transact-SQL )
sys.indexes (Transact-SQL )
sys.dm_db_index_physical_stats (Transact-SQL)
11/14/2018 • 23 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2008) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
Returns size and fragmentation information for the data and indexes of the specified table or view in SQL Server.
For an index, one row is returned for each level of the B -tree in each partition. For a heap, one row is returned for
the IN_ROW_DATA allocation unit of each partition. For large object (LOB ) data, one row is returned for the
LOB_DATA allocation unit of each partition. If row -overflow data exists in the table, one row is returned for the
ROW_OVERFLOW_DATA allocation unit in each partition. Does not return information about xVelocity memory
optimized columnstore indexes.
IMPORTANT
If you query sys.dm_db_index_physical_stats on a server instance that is hosting an Always On readable secondary
replica, you might encounter a REDO blocking issue. This is because this dynamic management view acquires an IS lock on
the specified user table or view that can block requests by a REDO thread for an X lock on that user table or view.
Syntax
sys.dm_db_index_physical_stats (
{ database_id | NULL | 0 | DEFAULT }
, { object_id | NULL | 0 | DEFAULT }
, { index_id | NULL | 0 | -1 | DEFAULT }
, { partition_number | NULL | 0 | DEFAULT }
, { mode | NULL | DEFAULT }
)
Arguments
database_id | NULL | 0 | DEFAULT
Is the ID of the database. database_id is smallint. Valid inputs are the ID number of a database, NULL, 0, or
DEFAULT. The default is 0. NULL, 0, and DEFAULT are equivalent values in this context.
Specify NULL to return information for all databases in the instance of SQL Server. If you specify NULL for
database_id, you must also specify NULL for object_id, index_id, and partition_number.
The built-in function DB_ID can be specified. When using DB_ID without specifying a database name, the
compatibility level of the current database must be 90 or greater.
object_id | NULL | 0 | DEFAULT
Is the object ID of the table or view the index is on. object_id is int.
Valid inputs are the ID number of a table and view, NULL, 0, or DEFAULT. The default is 0. NULL, 0, and
DEFAULT are equivalent values in this context. As of SQL Server 2016 (13.x), valid inputs also include the service
broker queue name or the queue internal table name. When default parameters are applied (i.e. all objects, all
indexes, etc), fragmentation information for all queues are included in the result set.
Specify NULL to return information for all tables and views in the specified database. If you specify NULL for
object_id, you must also specify NULL for index_id and partition_number.
index_id | 0 | NULL | -1 | DEFAULT
Is the ID of the index. index_id is int. Valid inputs are the ID number of an index, 0 if object_id is a heap, NULL, -1,
or DEFAULT. The default is -1. NULL, -1, and DEFAULT are equivalent values in this context.
Specify NULL to return information for all indexes for a base table or view. If you specify NULL for index_id, you
must also specify NULL for partition_number.
partition_number | NULL | 0 | DEFAULT
Is the partition number in the object. partition_number is int. Valid inputs are the partion_number of an index or
heap, NULL, 0, or DEFAULT. The default is 0. NULL, 0, and DEFAULT are equivalent values in this context.
Specify NULL to return information for all partitions of the owning object.
partition_number is 1-based. A nonpartitioned index or heap has partition_number set to 1.
mode | NULL | DEFAULT
Is the name of the mode. mode specifies the scan level that is used to obtain statistics. mode is sysname. Valid
inputs are DEFAULT, NULL, LIMITED, SAMPLED, or DETAILED. The default (NULL ) is LIMITED.
Table Returned
COLUMN NAME DATA TYPE DESCRIPTION
0 = Heap.
HEAP
CLUSTERED INDEX
NONCLUSTERED INDEX
SPATIAL INDEX
XML INDEX
IN_ROW_DATA
LOB_DATA
ROW_OVERFLOW_DATA
1 = Heap, or LOB_DATA or
ROW_OVERFLOW_DATA allocation
unit.
COLUMN NAME DATA TYPE DESCRIPTION
For LOB_DATA or
ROW_OVERFLOW_DATA allocation
units, total number of pages in the
allocation unit.
For LOB_DATA or
ROW_OVERFLOW_DATA allocation
units, the total number of records in
the complete allocation unit.
For LOB_DATA or
ROW_OVERFLOW_DATA allocation
units, the minimum record size in the
complete allocation unit.
For LOB_DATA or
ROW_OVERFLOW_DATA allocation
units, the maximum record size in the
complete allocation unit.
For LOB_DATA or
ROW_OVERFLOW_DATA allocation
units, the average record size in the
complete allocation unit.
NULL if
COLUMN NAME DATA TYPE DESCRIPTION
0 = NOT_APPLICABLE
1 = OPEN
2 = DRAINING
3 = FLUSHING
4 = RETIRING
5 = READY
Remarks
The sys.dm_db_index_physical_stats dynamic management function replaces the DBCC SHOWCONTIG
statement.
Scanning Modes
The mode in which the function is executed determines the level of scanning performed to obtain the statistical
data that is used by the function. mode is specified as LIMITED, SAMPLED, or DETAILED. The function traverses
the page chains for the allocation units that make up the specified partitions of the table or index.
sys.dm_db_index_physical_stats requires only an Intent-Shared (IS ) table lock, regardless of the mode that it runs
in.
The LIMITED mode is the fastest mode and scans the smallest number of pages. For an index, only the parent-
level pages of the B -tree (that is, the pages above the leaf level) are scanned. For a heap, the associated PFS and
IAM pages are examined and the data pages of a heap are scanned in LIMITED mode.
With LIMITED mode, compressed_page_count is NULL because the Database Engine only scans non-leaf pages
of the B -tree and the IAM and PFS pages of the heap. Use SAMPLED mode to get an estimated value for
compressed_page_count, and use DETAILED mode to get the actual value for compressed_page_count. The
SAMPLED mode returns statistics based on a 1 percent sample of all the pages in the index or heap. Results in
SAMPLED mode should be regarded as approximate. If the index or heap has fewer than 10,000 pages,
DETAILED mode is used instead of SAMPLED.
The DETAILED mode scans all pages and returns all statistics.
The modes are progressively slower from LIMITED to DETAILED, because more work is performed in each
mode. To quickly gauge the size or fragmentation level of a table or index, use the LIMITED mode. It is the fastest
and will not return a row for each nonleaf level in the IN_ROW_DATA allocation unit of the index.
USE master;
GO
-- In this example, OBJECT_ID is evaluated in the context of the master database.
-- Because Person.Address does not exist in master, the function returns NULL.
-- When NULL is specified as an object_id, all objects in the database are returned.
-- The same results are returned when an object that is not valid is specified.
SELECT * FROM sys.dm_db_index_physical_stats
(DB_ID(N'AdventureWorks'), OBJECT_ID(N'Person.Address'), NULL, NULL , 'DETAILED');
GO
-- This example demonstrates the results of specifying a valid object name
-- that exists in both the current database context and
-- in the database specified in the database_id parameter of the
-- sys.dm_db_index_physical_stats function.
-- An error is returned because the ID value returned by OBJECT_ID does not
-- match the ID value of the object in the specified database.
CREATE DATABASE Test;
GO
USE Test;
GO
CREATE SCHEMA Person;
GO
CREATE Table Person.Address(c1 int);
GO
USE AdventureWorks2012;
GO
SELECT * FROM sys.dm_db_index_physical_stats
(DB_ID(N'Test'), OBJECT_ID(N'Person.Address'), NULL, NULL , 'DETAILED');
GO
-- Clean up temporary database.
DROP DATABASE Test;
GO
Best Practice
Always make sure that a valid ID is returned when you use DB_ID or OBJECT_ID. For example, when you use
OBJECT_ID, specify a three-part name such as OBJECT_ID(N'AdventureWorks2012.Person.Address') , or test the value
returned by the functions before you use them in the sys.dm_db_index_physical_stats function. Examples A and B
that follow demonstrate a safe way to specify database and object IDs.
Detecting Fragmentation
Fragmentation occurs through the process of data modifications (INSERT, UPDATE, and DELETE statements) that
are made against the table and, therefore, to the indexes defined on the table. Because these modifications are not
ordinarily distributed equally among the rows of the table and indexes, the fullness of each page can vary over
time. For queries that scan part or all of the indexes of a table, this kind of fragmentation can cause additional
page reads. This hinders parallel scanning of data.
The fragmentation level of an index or heap is shown in the avg_fragmentation_in_percent column. For heaps, the
value represents the extent fragmentation of the heap. For indexes, the value represents the logical fragmentation
of the index. Unlike DBCC SHOWCONTIG, the fragmentation calculation algorithms in both cases consider
storage that spans multiple files and, therefore, are accurate.
Logical Fragmentation
This is the percentage of out-of-order pages in the leaf pages of an index. An out-of-order page is a page for
which the next physical page allocated to the index is not the page pointed to by the next-page pointer in the
current leaf page.
Extent Fragmentation
This is the percentage of out-of-order extents in the leaf pages of a heap. An out-of-order extent is one for which
the extent that contains the current page for a heap is not physically the next extent after the extent that contains
the previous page.
The value for avg_fragmentation_in_percent should be as close to zero as possible for maximum performance.
However, values from 0 percent through 10 percent may be acceptable. All methods of reducing fragmentation,
such as rebuilding, reorganizing, or re-creating, can be used to reduce these values. For more information about
how to analyze the degree of fragmentation in an index, see Reorganize and Rebuild Indexes.
NOTE
Running DBCC SHRINKFILE or DBCC SHRINKDATABASE may introduce fragmentation if an index is partly or completely
moved during the shrink operation. Therefore, if a shrink operation must be performed, you should do it before
fragmentation is removed.
Creating and dropping a clustered index on a table, rebuilds all non-clustered indexes on that table twice.
Permissions
Requires the following permissions:
CONTROL permission on the specified object within the database.
VIEW DATABASE STATE permission to return information about all objects within the specified database,
by using the object wildcard @object_id=NULL.
VIEW SERVER STATE permission to return information about all databases, by using the database
wildcard @database_id = NULL.
Granting VIEW DATABASE STATE allows all objects in the database to be returned, regardless of any
CONTROL permissions denied on specific objects.
Denying VIEW DATABASE STATE disallows all objects in the database to be returned, regardless of any
CONTROL permissions granted on specific objects. Also, when the database wildcard
@database_id=NULL is specified, the database is omitted.
For more information, see Dynamic Management Views and Functions (Transact-SQL ).
Examples
A. Returning information about a specified table
The following example returns size and fragmentation statistics for all indexes and partitions of the
Person.Address table. The scan mode is set to 'LIMITED' for best performance and to limit the statistics that are
returned. Executing this query requires, at a minimum, CONTROL permission on the Person.Address table.
IF @db_id IS NULL
BEGIN;
PRINT N'Invalid database';
END;
ELSE IF @object_id IS NULL
BEGIN;
PRINT N'Invalid object';
END;
ELSE
BEGIN;
SELECT * FROM sys.dm_db_index_physical_stats(@db_id, @object_id, NULL, NULL , 'LIMITED');
END;
GO
SELECT o.name,
ips.partition_number,
ips.index_type_desc,
ips.record_count, ips.avg_record_size_in_bytes,
ips.min_record_size_in_bytes,
ips.max_record_size_in_bytes,
ips.page_count, ips.compressed_page_count
FROM sys.dm_db_index_physical_stats ( DB_ID(), NULL, NULL, NULL, 'DETAILED') ips
JOIN sys.objects o on o.object_id = ips.object_id
ORDER BY record_count DESC;
See Also
Dynamic Management Views and Functions (Transact-SQL )
Index Related Dynamic Management Views and Functions (Transact-SQL )
sys.dm_db_index_operational_stats (Transact-SQL )
sys.dm_db_index_usage_stats (Transact-SQL )
sys.dm_db_partition_stats (Transact-SQL )
sys.allocation_units (Transact-SQL )
System Views (Transact-SQL )
sys.dm_db_index_usage_stats (Transact-SQL)
10/1/2018 • 3 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2008) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
Returns counts of different types of index operations and the time each type of operation was last performed.
In Azure SQL Database, dynamic management views cannot expose information that would impact database
containment or expose information about other databases the user has access to. To avoid exposing this
information, every row that contains data that doesn’t belong to the connected tenant is filtered out.
NOTE
sys.dm_db_index_usage_stats does not return information about memory-optimized indexes. For information about
memory-optimized index use, see sys.dm_db_xtp_index_stats (Transact-SQL).
NOTE
To call this view from Azure SQL Data Warehouse or Parallel Data Warehouse, use
sys.dm_pdw_nodes_db_index_usage_stats.
Remarks
Every individual seek, scan, lookup, or update on the specified index by one query execution is counted as a use of
that index and increments the corresponding counter in this view. Information is reported both for operations
caused by user-submitted queries, and for operations caused by internally generated queries, such as scans for
gathering statistics.
The user_updates counter indicates the level of maintenance on the index caused by insert, update, or delete
operations on the underlying table or view. You can use this view to determine which indexes are used only lightly
by your applications. You can also use the view to determine which indexes are incurring maintenance overhead.
You may want to consider dropping indexes that incur maintenance overhead, but are not used for queries, or are
only infrequently used for queries.
The counters are initialized to empty whenever the SQL Server (MSSQLSERVER ) service is started. In addition,
whenever a database is detached or is shut down (for example, because AUTO_CLOSE is set to ON ), all rows
associated with the database are removed.
When an index is used, a row is added to sys.dm_db_index_usage_stats if a row does not already exist for the
index. When the row is added, its counters are initially set to zero.
During upgrade to SQL Server 2008 R2, SQL Server 2012 (11.x), or SQL Server 2014 (12.x), entries in
sys.dm_db_index_usage_stats are removed. Beginning with SQL Server 2016 (13.x), entries are retained as they
were prior to SQL Server 2008 R2.
Permissions
On SQL Server, requires VIEW SERVER STATE permission.
On SQL Database, requires the VIEW DATABASE STATE permission in the database.
See Also
Index Related Dynamic Management Views and Functions (Transact-SQL )
sys.dm_db_index_physical_stats (Transact-SQL )
sys.dm_db_index_operational_stats (Transact-SQL )
sys.indexes (Transact-SQL )
sys.objects (Transact-SQL )
Monitor and Tune for Performance
sys.dm_db_missing_index_columns (Transact-SQL)
10/1/2018 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2008) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
Returns information about database table columns that are missing an index, excluding spatial indexes.
sys.dm_db_missing_index_columns is a dynamic management function.
Syntax
sys.dm_db_missing_index_columns(index_handle)
Arguments
index_handle
An integer that uniquely identifies a missing index. It can be obtained from the following dynamic management
objects:
sys.dm_db_missing_index_details (Transact-SQL )
sys.dm_db_missing_index_groups (Transact-SQL )
Table Returned
COLUMN NAME DATA TYPE DESCRIPTION
Transaction Consistency
If a transaction creates or drops a table, the rows containing missing index information about the dropped objects
are removed from this dynamic management object, preserving transaction consistency.
Permissions
Users must be granted the VIEW SERVER STATE permission or any permission that implies the VIEW SERVER
STATE permission to query this dynamic management function.
Examples
The following example runs a query against the Address table and then runs a query using the
sys.dm_db_missing_index_columns dynamic management view to return the table columns that are missing an
index.
USE AdventureWorks2012;
GO
SELECT City, StateProvinceID, PostalCode
FROM Person.Address
WHERE StateProvinceID = 9;
GO
SELECT mig.*, statement AS table_name,
column_id, column_name, column_usage
FROM sys.dm_db_missing_index_details AS mid
CROSS APPLY sys.dm_db_missing_index_columns (mid.index_handle)
INNER JOIN sys.dm_db_missing_index_groups AS mig ON mig.index_handle = mid.index_handle
ORDER BY mig.index_group_handle, mig.index_handle, column_id;
GO
See Also
sys.dm_db_missing_index_details (Transact-SQL )
sys.dm_db_missing_index_groups (Transact-SQL )
sys.dm_db_missing_index_group_stats (Transact-SQL )
sys.dm_db_missing_index_details (Transact-SQL)
10/1/2018 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2008) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
Returns detailed information about missing indexes, excluding spatial indexes.
In Azure SQL Database, dynamic management views cannot expose information that would impact database
containment or expose information about other databases the user has access to. To avoid exposing this
information, every row that contains data that doesn’t belong to the connected tenant is filtered out.
table.column =constant_value
NOTE
The result set for this DMV is limited to 600 rows. Each row contains one missing index. If you have more than 600 missing
indexes, you should address the existing missing indexes so you can then view the newer ones.
Transaction Consistency
If a transaction creates or drops a table, the rows containing missing index information about the dropped objects
are removed from this dynamic management object, preserving transaction consistency.
Permissions
On SQL Server, requires VIEW SERVER STATE permission.
On SQL Database, requires the VIEW DATABASE STATE permission in the database.
See Also
sys.dm_db_missing_index_columns (Transact-SQL )
sys.dm_db_missing_index_groups (Transact-SQL )
sys.dm_db_missing_index_group_stats (Transact-SQL )
sys.dm_db_missing_index_groups (Transact-SQL)
10/1/2018 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2008) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
This DMV returns information about indexes that are missing in a specific index group, except for spatial indexes.
In Azure SQL Database, dynamic management views cannot expose information that would impact database
containment or expose information about other databases the user has access to. To avoid exposing this
information, every row that contains data that doesn’t belong to the connected tenant is filtered out.
Remarks
Information returned by sys.dm_db_missing_index_groups is updated when a query is optimized by the query
optimizer, and is not persisted. Missing index information is kept only until SQL Server is restarted. Database
administrators should periodically make backup copies of the missing index information if they want to keep it
after server recycling.
Neither column of the output result set is a key, but together they form an index key.
NOTE
The result set for this DMV is limited to 600 rows. Each row contains one missing index. If you have more than 600 missing
indexes, you should address the existing missing indexes so you can then view the newer ones.
Permissions
To query this dynamic management view, users must be granted the VIEW SERVER STATE permission or any
permission that implies the VIEW SERVER STATE permission.
See Also
sys.dm_db_missing_index_columns (Transact-SQL )
sys.dm_db_missing_index_details (Transact-SQL )
sys.dm_db_missing_index_group_stats (Transact-SQL )
sys.dm_db_missing_index_group_stats (Transact-SQL)
10/1/2018 • 4 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2008) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
Returns summary information about groups of missing indexes, excluding spatial indexes.
In Azure SQL Database, dynamic management views cannot expose information that would impact database
containment or expose information about other databases the user has access to. To avoid exposing this
information, every row that contains data that doesn’t belong to the connected tenant is filtered out.
Remarks
Information returned by sys.dm_db_missing_index_group_stats is updated by every query execution, not by
every query compilation or recompilation. Usage statistics are not persisted and are kept only until SQL Server is
restarted. Database administrators should periodically make backup copies of the missing index information if
they want to keep the usage statistics after server recycling.
NOTE
The result set for this DMV is limited to 600 rows. Each row contains one missing index. If you have more than 600 missing
indexes, you should address the existing missing indexes so you can then view the newer ones.
Permissions
To query this dynamic management view, users must be granted the VIEW SERVER STATE permission or any
permission that implies the VIEW SERVER STATE permission.
Examples
The following examples illustrate how to use the sys.dm_db_missing_index_group_stats dynamic management
view.
A. Find the 10 missing indexes with the highest anticipated improvement for user queries
The following query determines which 10 missing indexes would produce the highest anticipated cumulative
improvement, in descending order, for user queries.
SELECT TOP 10 *
FROM sys.dm_db_missing_index_group_stats
ORDER BY avg_total_user_cost * avg_user_impact * (user_seeks + user_scans)DESC;
B. Find the individual missing indexes and their column details for a particular missing index group
The following query determines which missing indexes comprise a particular missing index group, and displays
their column details. For the sake of this example, the missing index group handle is 24.
This query provides the name of the database, schema, and table where an index is missing. It also provides the
names of the columns that should be used for the index key. When writing the CREATE INDEX DDL statement to
implement missing indexes, list equality columns first and then inequality columns in the ON <table_name>
clause of the CREATE INDEX statement. Included columns should be listed in the INCLUDE clause of the CREATE
INDEX statement. To determine an effective order for the equality columns, order them based on their selectivity,
listing the most selective columns first (leftmost in the column list).
See Also
sys.dm_db_missing_index_columns (Transact-SQL )
sys.dm_db_missing_index_details (Transact-SQL )
sys.dm_db_missing_index_groups (Transact-SQL )
CREATE INDEX (Transact-SQL )
I O Related Dynamic Management Views and
Functions (Transact-SQL)
11/14/2018 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2012) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
This section contains the following dynamic management objects.
sys.dm_io_cluster_valid_path_names (Transact-SQL)
See Also
Dynamic Management Views and Functions (Transact-SQL )
System Views (Transact-SQL )
sys.dm_io_backup_tapes (Transact-SQL)
10/1/2018 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2008) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
Returns the list of tape devices and the status of mount requests for backups.
2 = Mount pending
3 = In use
4 = Loading
Is not nullable.
AVAILABLE
MOUNT PENDING
IN USE
LOADING MEDIA
Is not nullable.
1 = Read
2 = Format
3 = Init
4 = Append
Is nullable.
READ
FORMAT
INIT
APPEND
Is nullable.
COLUMN NAME DATA TYPE DESCRIPTION
Is nullable.
SPECIFIC TAPE
CONTINUATION VOLUME
Is nullable.
Permissions
The user must have VIEW SERVER STATE permission on the server.
See Also
Dynamic Management Views and Functions (Transact-SQL )
I O Related Dynamic Management Views and Functions (Transact-SQL )
sys.dm_io_cluster_shared_drives (Transact-SQL)
10/1/2018 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2008) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
This view returns the drive name of each of the shared drives if the current server instance is a clustered server. If
the current server instance is not a clustered instance it returns an empty rowset.
NOTE
To call this from Parallel Data Warehouse, use the name sys.dm_pdw_nodes_io_cluster_shared_drives.
Remarks
When clustering is enabled, the failover cluster instance requires data and log files to be on shared disks so that
they may be accessed after the instance fails over to another node. Each of the rows in this view represents a
single shared disk which is used by this clustered SQL Server instance. Only disks listed by this view can be used
to store data or log files for this instance of SQL Server. The disks listed in this view are those that are in the
cluster resource group associated with the instance.
NOTE
This view will be deprecated in a future release. We recommend that you use sys.dm_io_cluster_valid_path_names (Transact-
SQL) instead.
Permissions
The user must have VIEW SERVER STATE permission for the SQL Server instance.
Examples
The following example uses sys.dm_io_cluster_shared_drives to determine the shared drives on a clustered server
instance:
See Also
sys.dm_io_cluster_valid_path_names (Transact-SQL )
sys.dm_os_cluster_nodes (Transact-SQL )
sys.fn_servershareddrives (Transact-SQL )
Dynamic Management Views and Functions (Transact-SQL )
sys.dm_io_pending_io_requests (Transact-SQL)
10/1/2018 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2008) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
Returns a row for each pending I/O request in SQL Server.
NOTE
To call this from Azure SQL Data Warehouse or Parallel Data Warehouse, use the name
sys.dm_pdw_nodes_io_pending_io_requests.
Permissions
On SQL Server, requires VIEW SERVER STATE permission.
On SQL Database, requires the VIEW DATABASE STATE permission in the database.
See Also
Dynamic Management Views and Functions (Transact-SQL )
I O Related Dynamic Management Views and Functions (Transact-SQL )
sys.dm_io_virtual_file_stats (Transact-SQL)
10/1/2018 • 3 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2008) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
Returns I/O statistics for data and log files. This dynamic management view replaces the fn_virtualfilestats
function.
NOTE
To call this from Azure SQL Data Warehouse, use the name sys.dm_pdw_nodes_io_virtual_file_stats.
Syntax
-- Syntax for SQL Server and Azure SQL Database
sys.dm_io_virtual_file_stats (
{ database_id | NULL },
{ file_id | NULL }
)
sys.dm_pdw_nodes_io_virtual_file_stats
Arguments
database_id | NULL
APPLIES TO: SQL Server (starting with 2008), Azure SQL Database
ID of the database. database_id is int, with no default. Valid inputs are the ID number of a database or NULL.
When NULL is specified, all databases in the instance of SQL Server are returned.
The built-in function DB_ID can be specified.
file_id | NULL
APPLIES TO: SQL Server (starting with 2008), Azure SQL Database
ID of the file. file_id is int, with no default. Valid inputs are the ID number of a file or NULL. When NULL is
specified, all files on the database are returned.
The built-in function FILE_IDEX can be specified, and refers to a file in the current database.
Table Returned
COLUMN NAME DATA TYPE DESCRIPTION
COLUMN NAME DATA TYPE DESCRIPTION
Permissions
Requires VIEW SERVER STATE permission. For more information, see Dynamic Management Views and
Functions (Transact-SQL ).
Examples
A. Return statistics for a log file
Applies to: SQL Server (starting with 2008), Azure SQL Database
The following example returns statistics for the log file in the AdventureWorks2012 database.
See Also
Dynamic Management Views and Functions (Transact-SQL )
I O Related Dynamic Management Views and Functions (Transact-SQL )
sys.database_files (Transact-SQL )
sys.master_files (Transact-SQL )
sys.dm_io_cluster_valid_path_names (Transact-SQL)
10/1/2018 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2014) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
Returns information on all valid shared disks, including clustered shared volumes, for a SQL Server failover
cluster instance. If the instance is not clustered, an empty rowset is returned.
Remarks
A SQL Server failover cluster instance (FCI) must use shared storage between all nodes of the FCI for data and
log file storage. The disks listed in this view are those that are in the cluster resource group associated with the
instance and are the only disks that can be used for data or log file storage.
NOTE
This view will replace sys.dm_io_cluster_shared_drives (Transact-SQL) in a future release.
Permissions
The user must have VIEW SERVER STATE permission for the SQL Server instance.
Examples
The following example uses sys.dm_io_cluster_valid_path_names to determine the shared drives on a clustered
server instance:
See Also
sys.dm_os_cluster_nodes (Transact-SQL )
sys.dm_io_cluster_shared_drives (Transact-SQL )
Dynamic Management Views and Functions (Transact-SQL )
Memory-Optimized Table Dynamic Management
Views (Transact-SQL)
10/1/2018 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2014) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
The following SQL Server dynamic management views (DMVs) are used with In-Memory OLTP:
For more information, see In-Memory OLTP (In-Memory Optimization).
sys.dm_xtp_transaction_stats (Transact-SQL)
Internal DMVs
There are additional DMVs that are intended for internal use only, and for which we provide no direct
documentation. In the area of memory-optimized tables, undocumented DMVs include the following:
sys.dm_xtp_threads
sys.dm_xtp_transaction_recent_rows
sys.dm_db_xtp_checkpoint_stats (Transact-SQL)
10/1/2018 • 4 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2014) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
Returns statistics about the In-Memory OLTP checkpoint operations in the current database. If the database has no
In-Memory OLTP objects, returns an empty result set.
For more information, see In-Memory OLTP (In-Memory Optimization).
SQL Server 2014 (12.x) is substantially different from more recent versions and is discussed lower in the
topic at SQL Server 2014.
Permissions
Requires VIEW DATABASE STATE permission on the server.
See Also
Memory-Optimized Table Dynamic Management Views (Transact-SQL )
sys.dm_db_xtp_checkpoint_files (Transact-SQL)
10/1/2018 • 8 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2014) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
Displays information about checkpoint files, including file size, physical location and the transaction ID.
NOTE: For the current checkpoint that has not closed, the state column of s ys.dm_db_xtp_checkpoint_files will
be UNDER CONSTRUCTION for new files. A checkpoint closes automatically when there is sufficient
transaction log growth since the last checkpoint, or if you issue the CHECKPOINT command (CHECKPOINT
(Transact-SQL )).
A memory-optimized file group internally uses append-only files to store inserted and deleted rows for in-
memory tables. There are two types of files. A data file contains inserted rows while a delta file contains references
to deleted rows.
SQL Server 2014 (12.x) is substantially different from more recent versions and is discussed lower in the topic at
SQL Server 2014.
For more information, see Creating and Managing Storage for Memory-Optimized Objects.
1 - UNDER CONSTRUCTION
2 - ACTIVE
3 – MERGE TARGET
encryption_status smallint 0, 1, 2
1 – UNDER CONSTRUCTION
2 - ACTIVE
3 – MERGE TARGET
4 – MERGED SOURCE
6 – IN TRANSITION TO TOMBSTONE
7 – TOMBSTONE
IN TRANSITION TO TOMBSTONE –
These CFPs are not needed by the In-
Memory OLTP engine and can they can
be garbage collected. This state
indicates that these CFPs are waiting for
the background thread to transition
them to the next state, which is
TOMBSTONE.
Permissions
Requires VIEW DATABASE STATE permission on the server.
Use Cases
You can estimate the storage used by In-Memory OLTP as follows:
To see a breakdown of storage utilization by state and file type run the following query:
SELECT state_desc
, file_type_desc
, COUNT(*) AS [count]
, SUM(file_size_in_bytes) / 1024 / 1024 AS [on-disk size MB]
FROM sys.dm_db_xtp_checkpoint_files
GROUP BY state, state_desc, file_type, file_type_desc
ORDER BY state, file_type
See Also
Memory-Optimized Table Dynamic Management Views (Transact-SQL )
sys.dm_db_xtp_gc_cycle_stats (Transact-SQL)
10/1/2018 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2014) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
Outputs the current state of committed transactions that have deleted one or more rows. The idle garbage
collection thread wakes every minute or when the number of committed DML transactions exceeds an internal
threshold since the last garbage collection cycle. As part of the garbage collection cycle, it moves the transactions
that have committed into one or more queues associated with generations. The transactions that have generated
stale versions are grouped in a unit of 16 transactions across 16 generations as follows:
Generation-0: This stores all transactions that committed earlier than the oldest active transaction. Row
versions generated by these transactions are immediately available for garbage collection.
Generations 1-14: Stores transactions with timestamp greater than the oldest active transaction. The row
versions cannot be garbage collected. Each generation can hold up to 16 transactions. A total of 224 (14 *
16) transactions can exist in these generations.
Generation 15: The remaining transactions with timestamp greater than the oldest active transaction go to
generation 15. Similar to generation-0, there is no limit of number of transactions in generation-15.
When there is memory pressure, the garbage collection thread updates the oldest active transaction hint
aggressively, which forces garbage collection.
For more information, see In-Memory OLTP (In-Memory Optimization).
Usage Scenario
Here is a sample output with a subset of columns, showing 27 generations:
1 123160509 123160509 1 0 0
2 123176822 123176822 1 0 1
3 123236826 123236826 1 0 1
4 123296829 123296829 1 0 1
5 123356832 123356941 129 0 0
6 123357473 123357473 129 0 0
7 123417486 123417486 129 0 0
8 123477489 123477489 129 0 0
9 123537492 123537492 129 0 0
10 123597500 123597500 129 0 0
11 123657504 123657504 129 0 0
12 123717507 123717507 129 0 0
13 123777510 123777510 129 0 0
14 123837513 123837513 129 0 0
15 123897516 123897516 129 0 0
16 123957516 123957516 129 0 0
17 124017516 124017516 129 0 0
18 124077517 124077517 129 0 0
19 124137517 124137517 129 0 0
20 124197518 124197518 129 0 0
21 124257518 124257518 129 0 0
22 124317523 124317523 129 0 0
23 124377526 124377526 129 0 0
24 124437529 124437529 129 0 0
25 124497533 124497533 129 0 0
26 124557536 124557536 129 0 0
27 124617539 124617539 129 0 0
See Also
Memory-Optimized Table Dynamic Management Views (Transact-SQL )
sys.dm_db_xtp_hash_index_stats (Transact-SQL)
10/1/2018 • 3 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2014) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
These statistics are useful for understanding and tuning the bucket counts. It can also be used to detect cases
where the index key has many duplicates.
A large average chain length indicates that many rows are hashed to the same bucket. This could happen because:
If the number of empty buckets is low or the average and maximum chain lengths are similar, it is likely that
the total bucket count is too low. This causes many different index keys to hash to the same bucket.
If the number of empty buckets is high or the maximum chain length is high relative to the average chain
length, it is likely that there are many rows with duplicate index key values or there is a skew in the key
values. All rows with the same index key value hash to the same bucket, hence there is a long chain length in
that bucket.
Long chain lengths can significantly impact the performance of all DML operations on individual rows, including
SELECT and INSERT. Short chain lengths along with a high empty bucket count are in indication of a bucket_count
that is too high. This decreases the performance of index scans.
WARNING
sys.dm_db_xtp_hash_index_stats scans the entire table. So, if there are large tables in your database,
sys.dm_db_xtp_hash_index_stats may take a long time run.
Permissions
Requires VIEW DATABASE STATE permission on the server.
Examples
A. Troubleshooting hash index bucket count
The following query can be used to troubleshoot the hash index bucket count of an existing table. The query
returns statistics about percentage of empty buckets and chain length for all hash indexes on user tables.
SELECT
QUOTENAME(SCHEMA_NAME(t.schema_id)) + N'.' + QUOTENAME(OBJECT_NAME(h.object_id)) as [table],
i.name as [index],
h.total_bucket_count,
h.empty_bucket_count,
FLOOR((
CAST(h.empty_bucket_count as float) /
h.total_bucket_count) * 100)
as [empty_bucket_percent],
h.avg_chain_length,
h.max_chain_length
FROM sys.dm_db_xtp_hash_index_stats as h
INNER JOIN sys.indexes as i
ON h.object_id = i.object_id
AND h.index_id = i.index_id
INNER JOIN sys.memory_optimized_tables_internal_attributes ia ON h.xtp_object_id=ia.xtp_object_id
INNER JOIN sys.tables t on h.object_id=t.object_id
WHERE ia.type=1
ORDER BY [table], [index];
For details on how to interpret the results of this query, see Troubleshooting Hash Indexes for Memory-Optimized
Tables .
B. Hash index statistics for internal tables
Certain features use internal tables that leverage hash indexes, for example columnstore indexes on memory-
optimized tables. The following query returns stats for hash indexes on internal tables that are linked to user tables.
SELECT
QUOTENAME(SCHEMA_NAME(t.schema_id)) + N'.' + QUOTENAME(OBJECT_NAME(h.object_id)) as [user_table],
ia.type_desc as [internal_table_type],
i.name as [index],
h.total_bucket_count,
h.empty_bucket_count,
h.avg_chain_length,
h.max_chain_length
FROM sys.dm_db_xtp_hash_index_stats as h
INNER JOIN sys.indexes as i
ON h.object_id = i.object_id
AND h.index_id = i.index_id
INNER JOIN sys.memory_optimized_tables_internal_attributes ia ON h.xtp_object_id=ia.xtp_object_id
INNER JOIN sys.tables t on h.object_id=t.object_id
WHERE ia.type!=1
ORDER BY [user_table], [internal_table_type], [index];
Note that the BUCKET_COUNT of index on internal tables cannot be changed, thus the output of this query should
be considered informative only. No action is required.
This query is not expected to return any rows unless you are using a feature that leverages hash indexes on
internal tables. The following memory-optimized table contains a columnstore index. After creating this table, you
will see hash indexes on internal tables.
See Also
Memory-Optimized Table Dynamic Management Views (Transact-SQL )
sys.dm_db_xtp_index_stats (Transact-SQL)
11/14/2018 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2014) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
Contains statistics collected since the last database restart.
For more information, see In-Memory OLTP (In-Memory Optimization) and Guidelines for Using Indexes on
Memory-Optimized Tables.
Permissions
Requires VIEW DATABASE STATE permission on the current database.
See Also
Memory-Optimized Table Dynamic Management Views (Transact-SQL )
sys.dm_db_xtp_memory_consumers (Transact-SQL)
10/1/2018 • 3 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2014) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
Reports the database-level memory consumers in the In-Memory OLTP database engine. The view returns a row
for each memory consumer that the database engine uses. Use this DMV to see how the memory is distributed
across different internal objects.
For more information, see In-Memory OLTP (In-Memory Optimization).
2 - VARHEAP
3 - HASH
5 - PGPOOL
COLUMN NAME DATA TYPE DESCRIPTION
VARHEAP:
Database heap. Used to allocate user
data for a database (rows).
Database System heap. Used to allocate
database data that will be included in
memory dumps and do not include
user data.
Range index heap. Private heap used by
range index to allocate BW pages.
Remarks
In the output, the allocators at database levels refer to user tables, indexes, and system tables. VARHEAP with
object_id = NULL refers to memory allocated to tables with variable length columns.
Permissions
All rows are returned if you have VIEW DATABASE STATE permission on the current database. Otherwise, an
empty rowset is returned.
If you do not have VIEW DATABASE permission, all columns will be returned for rows in tables that you have
SELECT permission on.
System tables are returned only for users with VIEW DATABASE STATE permission.
General Remarks
When a memory-optimized table has a columnstore index, the system uses some internal tables, which consume
some memory, to track data for the columnstore index. For details about these internal tables and sample queries
showing their memory consumption see sys.memory_optimized_tables_internal_attributes (Transact-SQL ) .
Examples
-- memory consumers (database level)
SELECT OBJECT_NAME(object_id), *
FROM sys.dm_db_xtp_memory_consumers;
User Scenario
-- memory consumers (database level)
Here is the output with a subset of columns. The allocators at database levels refer to user tables, indexes, and
system tables. The VARHEAP with object_id = NULL (last row ) refers to memory allocated to data rows of the
tables (in the example here, it is t1). The allocated bytes, when converted to MB, is 1340MB.
Name memory_consumer_type_desc object_id index_id allocated_bytes used_bytes
---------- ------------------------- ----------- ----------- -------------------- --------------------
t3 HASH 629577281 2 8388608 8388608
t2 HASH 597577167 2 8388608 8388608
t1 HASH 565577053 2 1048576 1048576
NULL HASH -6 1 2048 2048
NULL VARHEAP -6 NULL 0 0
NULL HASH -5 3 8192 8192
NULL HASH -5 2 8192 8192
NULL HASH -5 1 8192 8192
NULL HASH -4 1 2048 2048
NULL VARHEAP -4 NULL 0 0
NULL HASH -3 1 2048 2048
NULL HASH -2 2 8192 8192
NULL HASH -2 1 8192 8192
NULL VARHEAP -2 NULL 196608 26496
NULL HASH 0 1 2048 2048
NULL PGPOOL 0 NULL 0 0
NULL VARHEAP NULL NULL 1405943808 1231220560
The total memory allocated and used from this DMV is same as the object level in
sys.dm_db_xtp_table_memory_stats (Transact-SQL ) .
total_allocated_MB total_used_MB
-------------------- --------------------
1358 1191
See Also
Memory-Optimized Table Dynamic Management Views (Transact-SQL )
sys.dm_db_xtp_merge_requests (Transact-SQL)
10/1/2018 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2014) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
Tracks database merge requests. The merge request may have been generated by SQL Server or the request could
have been made by a user with sys.sp_xtp_merge_checkpoint_files (Transact-SQL ).
NOTE
This dynamic management view (DMV), sys.dm_db_xtp_merge_requests, exists until Microsoft SQL Server 2014.
But starting with SQL Server 2016 this DMV no longer applies.
Permissions
Requires VIEW DATABASE STATE permission on the current database.
See also
Memory-Optimized Table Dynamic Management Views (Transact-SQL )
sys.dm_db_xtp_nonclustered_index_stats (Transact-
SQL)
11/14/2018 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2014) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
sys.dm_db_xtp_nonclustered_index_stats includes statistics about operations on nonclustered indexes in memory-
optimized tables. sys.dm_db_xtp_nonclustered_index_stats contains one row for each nonclustered index on a
memory-optimized table in the current database.
The statistics reflected in sys.dm_db_xtp_nonclustered_index_stats are collected when the in-memory index
structure is created. In-memory index structures are recreated on database restart.
Use sys.dm_db_xtp_nonclustered_index_stats to understand and monitor index activity during DML operations and
when a database is brought online. When a database with a memory-optimized table is restarted, the index is built
by inserting one row at a time into memory. The count of page splits, merges, and consolidation can help you
understand the work done to build the index when a database is brought online. You can also look at these counts
before and after a series of DML operations.
Large numbers of retries are indicative of concurrency issues; call Microsoft Support.
For more information about memory-optimized, nonclustered indexes, see SQL Server In-Memory OLTP Internals
Overview, page 17.
Permissions
Requires VIEW DATABASE STATE permission on the current database.
See Also
Memory-Optimized Table Dynamic Management Views (Transact-SQL )
sys.dm_db_xtp_object_stats (Transact-SQL)
11/14/2018 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2014) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
Reports the number rows affected by operations on each of the In-Memory OLTP objects since the last database
restart. Statistics are updated when the operation executes, regardless of whether the transaction commits or was
rolled back.
sys.dm_db_xtp_object_stats can help you identify which memory-optimized tables are changing the most. You may
decide to remove unused or rarely used indexes on the table, as each index affects performance. If there are hash
indexes, you should periodically re-evaluate the bucket-count. For more information, see Determining the Correct
Bucket Count for Hash Indexes.
sys.dm_db_xtp_object_stats can help you identify which memory-optimized tables incur write-write conflicts, which
can affect the performance of your application. For example, if you have transaction retry logic, the same statement
may need to be executed more than once. Also, you can use this information to identify the tables (and therefore
business logic) that require write-write error handling.
The view contains a row for each memory optimized table in the database.
For more information, see In-Memory OLTP (In-Memory Optimization).
Permissions
Requires VIEW DATABASE STATE permission on the current database.
See Also
Memory-Optimized Table Dynamic Management Views (Transact-SQL )
sys.dm_db_xtp_table_memory_stats (Transact-SQL)
10/1/2018 • 3 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2014) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
Returns memory usage statistics for each In-Memory OLTP table (user and system) in the current database. The
system tables have negative object IDs and are used to store run-time information for the In-Memory OLTP
engine. Unlike user objects, system tables are internal and only exist in-memory, therefore, they are not visible
through catalog views. System tables are used to store information such as meta-data for all data/delta files in
storage, merge requests, watermarks for delta files to filter rows, dropped tables, and relevant information for
recovery and backups. Given that the In-Memory OLTP engine can have up to 8,192 data and delta file pairs, for
large in-memory databases, the memory taken by system tables can be a few megabytes.
For more information, see In-Memory OLTP (In-Memory Optimization).
Permissions
All rows are returned if you have VIEW DATABASE STATE permission on the current database. Otherwise, an
empty rowset is returned.
If you do not have VIEW DATABASE permission, all columns will be returned for rows in tables that you have
SELECT permission on.
System tables are returned only for users with VIEW DATABASE STATE permission.
Examples
You can query the following DMV to get the memory allocated for the tables and indexes within the database:
User Scenario
First create the following tables in a database called HkDb1.
-- set max server memory to 4 GB
EXEC sp_configure 'max server memory (MB)', 4048
go
RECONFIGURE
go
USE HkDb1
go
CONSTRAINT [pk_t1_c1] PRIMARY KEY NONCLUSTERED HASH (c1) WITH (BUCKET_COUNT = 100000)
) WITH (MEMORY_OPTIMIZED = ON, DURABILITY = SCHEMA_AND_DATA)
go
CONSTRAINT [pk_t2_c1] PRIMARY KEY NONCLUSTERED HASH (c1) WITH (BUCKET_COUNT = 100000)
) WITH (MEMORY_OPTIMIZED = ON, DURABILITY = SCHEMA_AND_DATA)
go
CONSTRAINT [pk_t3_c1] PRIMARY KEY NONCLUSTERED HASH (c1) WITH (BUCKET_COUNT = 1000000)
) WITH (MEMORY_OPTIMIZED = ON, DURABILITY = SCHEMA_AND_DATA)
go
When data is loaded into a table, you can see user defined tables and how much storage it is using. For example,
each row of a table could be approximately 8070 bytes (allocation size is 8K (8192 bytes)). You can see indexes per
table and how much storage the index uses. For example, 1MB is 100K entries rounded to the next power of 2
(2**17) = 131072 of 8 bytes each. A table may not have an index, in which case it will show memory allocation for
the index. Other rows may represent system tables
memory_allocated_for_indexes_kb memory_used_by_indexes_kb
------------------------------- -------------------------
8192 8192
1024 1024
8192 8192
2 2
24 24
2 2
2 2
16 16
is,
total_allocated_MB total_used_MB
-------------------- --------------------
1357 1191
Next, let's look at the output from the resource pool. Note, that memory used from the pool is 1356 MB
used_memory_mb target_memory_mb
-------------------- --------------------
125 3845
32 3845
1356 3845
See Also
Memory-Optimized Table Dynamic Management Views (Transact-SQL )
sys.dm_db_xtp_transactions (Transact-SQL)
10/1/2018 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2014) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
Reports the active transactions in the In-Memory OLTP database engine.
For more information, see In-Memory OLTP (In-Memory Optimization).
0=ACTIVE
1=COMMITTED
2=ABORTED
3=VALIDATING
0 - IN PROGRESS
1 - SUCCESS
2 - ERROR
3 - COMMIT DEPENDENCY
6 - ROLLBACK
IN PROGRESS
SUCCESS
ERROR
COMMIT DEPENDENCY
ROLLBACK
Permissions
Requires VIEW DATABASE STATE permission on the server.
See Also
Memory-Optimized Table Dynamic Management Views (Transact-SQL )
sys.dm_xtp_gc_queue_stats (Transact-SQL)
10/1/2018 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2014) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
Outputs information about each garbage collection worker queue on the server, and various statistics about each.
There is one queue per logical CPU.
The main garbage collection thread (the Idle thread) tracks updated, deleted, and inserted rows for all transactions
completed since the last invocation of the main garbage collection thread. When the garbage collection thread
wakes, it determines if the timestamp of the oldest active transaction has changed. If the oldest active transaction
has changed, then the idle thread enqueues work items (in chunks of 16 rows) for transactions whose write sets
are no longer needed. For example, if you delete 1,024 rows, you will eventually see 64 garbage collection work
items queued, each containing 16 deleted rows. After a user transaction commits, it selects all enqueued items on
its scheduler. If there are no enqueued items on its scheduler, the user transaction will search on any queue in the
current NUMA node.
You can determine if garbage collection is freeing memory for deleted rows by executing
sys.dm_xtp_gc_queue_stats to see if the enqueued work is being processed. If entries in the current_queue_depth
are not being processed or if no new work items are being added to the current_queue_depth, this is an indication
that garbage collection is not freeing memory. For example, garbage collection can’t be done if there is a long
running transaction.
For more information, see In-Memory OLTP (In-Memory Optimization).
Permissions
Requires VIEW SERVER STATE permission.
User Scenario
This output shows that SQL Server is either running on 4 cores or SQL Server instance has been affinitized to 4
cores:
This output shows that there are no work items in the queues to process. For queue 0, the total work items de-
queued since SQL Startup are 15625 and the max queue depth has been 215625.
See Also
Memory-Optimized Table Dynamic Management Views (Transact-SQL )
sys.dm_xtp_gc_stats (Transact-SQL)
10/1/2018 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2014) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
Provides information (the overall statistics) about the current behavior of the In-Memory OLTP garbage-collection
process.
Rows are garbage collected as part of regular transaction processing, or by the main garbage collection thread,
which is referred to as the idle worker. When a user transaction commits, it dequeues one work item from the
garbage collection queue (sys.dm_xtp_gc_queue_stats (Transact-SQL )). Any rows that could be garbage collected
but were not accessed by main user transaction are garbage collected by the idle worker, as part of the dusty
corner scan (a scan for areas of the index that are less accessed).
For more information, see In-Memory OLTP (In-Memory Optimization).
Permissions
Requires VIEW SERVER STATE permission on the instance.
Usage Scenario
The following is sample output:
See Also
Memory-Optimized Table Dynamic Management Views (Transact-SQL )
sys.dm_xtp_system_memory_consumers (Transact-
SQL)
10/1/2018 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2014) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
Reports system level memory consumers for In-Memory OLTP. The memory for these consumers come either
from the default pool (when the allocation is in the context of a user thread) or from internal pool (if the allocation
is in the context of a system thread).
1 – LOOKASIDE
2 - VARHEAP
4 - PGPOOL
COLUMN NAME TYPE DESCRIPTION
VARHEAP:
System heap. General purpose.
Currently only used to allocate garbage
collection work items.
-OR-
Lookaside heap. Used by looksides
when the number of items contained in
the lookaside list reaches a
predetermined cap (usually around
5,000 items).
Permissions
Requires VIEW SERVER STATE permissions on the server.
User Scenario
-- system memory consumers @ instance
selectmemory_consumer_type_desc,
allocated_bytes/1024 as allocated_bytes_kb,
used_bytes/1024 as used_bytes_kb, allocation_count
from sys.dm_xtp_system_memory_consumers
The output shows all memory consumers at system level. For example, there are consumers for transaction look
aside.
total_allocated_MB total_used_MB
-------------------- --------------------
2 2
See Also
Memory-Optimized Table Dynamic Management Views (Transact-SQL )
sys.dm_xtp_transaction_stats (Transact-SQL)
10/1/2018 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2012) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
Reports statistics about transactions that have run since the server started.
For more information, see In-Memory OLTP (In-Memory Optimization).
Permissions
Requires VIEW SERVER STATE permission on the server.
See Also
Memory-Optimized Table Dynamic Management Views (Transact-SQL )
Object Related Dynamic Management Views and
Functions (Transact-SQL)
11/14/2018 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2012) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
This section contains the following dynamic management objects in SQL Server.
sys.dm_db_incremental_stats_properties sys.dm_db_stats_histogram
sys.dm_db_stats_properties sys.dm_sql_referenced_entities
sys.dm_sql_referencing_entities
See Also
Dynamic Management Views and Functions (Transact-SQL )
System Views (Transact-SQL )
sys.dm_db_incremental_stats_properties (Transact-
SQL)
10/1/2018 • 3 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2014) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
Returns properties of incremental statistics for the specified database object (table) in the current SQL Server
database. The use of sys.dm_db_incremental_stats_properties (which contains a partition number) is similar to
sys.dm_db_stats_properties which is used for non-incremental statistics.
This function was introduced in SQL Server 2014 (12.x) Service Pack 2 and SQL Server 2016 (13.x) Service Pack
1.
Syntax
sys.dm_db_incremental_stats_properties (object_id, stats_id)
Arguments
object_id
Is the ID of the object in the current database for which properties of one of its incremental statistics is requested.
object_id is int.
stats_id
Is the ID of statistics for the specified object_id. The statistics ID can be obtained from the sys.stats dynamic
management view. stats_id is int.
Table Returned
COLUMN NAME DATA TYPE DESCRIPTION
Remarks
sys.dm_db_incremental_stats_properties returns an empty rowset under any of the following conditions:
object_id or stats_id is NULL.
The specified object is not found or does not correspond to a table with incremental statistics.
The specified statistics ID does not correspond to existing statistics for the specified object ID.
The current user does not have permissions to view the statistics object.
This behavior allows for the safe usage of sys.dm_db_incremental_stats_properties when cross applied to
rows in views such as sys.objects and sys.stats . This method can return properties for the statistics that
correspond to each partition. To see the properties for the merged statistics combined across all partitions,
use the sys.dm_db_stats_properties instead.
Statistics update date is stored in the statistics blob object together with the histogram and density vector, not in
the metadata. When no data is read to generate statistics data, the statistics blob is not created, the date is not
available, and the last_updated column is NULL. This is the case for filtered statistics for which the predicate does
not return any rows, or for new empty tables.
Permissions
Requires that the user has select permissions on statistics columns or the user owns the table or the user is a
member of the sysadmin fixed server role, the db_owner fixed database role, or the db_ddladmin fixed database
role.
Examples
A. Simple example
The following example returns the statistics for the PartitionTable table described in the topic Create Partitioned
Tables and Indexes.
See Also
DBCC SHOW_STATISTICS (Transact-SQL )
sys.stats (Transact-SQL )
Object Related Dynamic Management Views and Functions (Transact-SQL )
Dynamic Management Views and Functions (Transact-SQL )
sys.dm_db_stats_properties
sys.dm_db_stats_histogram (Transact-SQL )
sys.dm_db_stats_histogram (Transact-SQL)
10/1/2018 • 4 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2016) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
Returns the statistics histogram for the specified database object (table or indexed view ) in the current SQL Server
database. Similar to DBCC SHOW_STATISTICS WITH HISTOGRAM .
NOTE
This DMF is available starting with SQL Server 2016 (13.x) SP1 CU2
Syntax
sys.dm_db_stats_histogram (object_id, stats_id)
Arguments
object_id
Is the ID of the object in the current database for which properties of one of its statistics is requested. object_id is
int.
stats_id
Is the ID of statistics for the specified object_id. The statistics ID can be obtained from the sys.stats dynamic
management view. stats_id is int.
Table Returned
COLUMN NAME DATA TYPE DESCRIPTION
Remarks
The resultset for sys.dm_db_stats_histogram returns information similar to DBCC SHOW_STATISTICS WITH HISTOGRAM
and also includes object_id , stats_id , and step_number .
Because the column range_high_key is a sql_variant data type, you may need to use CAST or CONVERT if a
predicate does comparison with a non-string constant.
Histogram
A histogram measures the frequency of occurrence for each distinct value in a data set. The query optimizer
computes a histogram on the column values in the first key column of the statistics object, selecting the column
values by statistically sampling the rows or by performing a full scan of all rows in the table or view. If the
histogram is created from a sampled set of rows, the stored totals for number of rows and number of distinct
values are estimates and do not need to be whole integers.
To create the histogram, the query optimizer sorts the column values, computes the number of values that match
each distinct column value and then aggregates the column values into a maximum of 200 contiguous histogram
steps. Each step includes a range of column values followed by an upper bound column value. The range includes
all possible column values between boundary values, excluding the boundary values themselves. The lowest of the
sorted column values is the upper boundary value for the first histogram step.
The following diagram shows a histogram with six steps. The area to the left of the first upper boundary value is
the first step.
Permissions
Requires that the user has select permissions on statistics columns or the user owns the table or the user is a
member of the sysadmin fixed server role, the db_owner fixed database role, or the db_ddladmin fixed database
role.
Examples
A. Simple example
The following example creates and populates a simple table. Then creates statistics on the Country_Name column.
The primary key occupies stat_id number 1, so call sys.dm_db_stats_histogram for stat_id number 2, to return
the statistics histogram for the Country table.
B. Useful query:
C. Useful query:
The following example selects from table Country with a predicate on column Country_Name .
The following example looks at the previously created statistic on table Country and column Country_Name for the
histogram step matching the predicate in the query above.
SELECT ss.name, ss.stats_id, shr.steps, shr.rows, shr.rows_sampled,
shr.modification_counter, shr.last_updated, sh.range_rows, sh.equal_rows
FROM sys.stats ss
INNER JOIN sys.stats_columns sc
ON ss.stats_id = sc.stats_id AND ss.object_id = sc.object_id
INNER JOIN sys.all_columns ac
ON ac.column_id = sc.column_id AND ac.object_id = sc.object_id
CROSS APPLY sys.dm_db_stats_properties(ss.object_id, ss.stats_id) shr
CROSS APPLY sys.dm_db_stats_histogram(ss.object_id, ss.stats_id) sh
WHERE ss.[object_id] = OBJECT_ID('Country')
AND ac.name = 'Country_Name'
AND sh.range_high_key = CAST('Canada' AS CHAR(8));
See Also
DBCC SHOW_STATISTICS (Transact-SQL )
Object Related Dynamic Management Views and Functions (Transact-SQL )
sys.dm_db_stats_properties (Transact-SQL )
sys.dm_db_stats_properties (Transact-SQL)
10/1/2018 • 3 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2008) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
Returns properties of statistics for the specified database object (table or indexed view ) in the current SQL Server
database. For partitioned tables, see the similar sys.dm_db_incremental_stats_properties.
Syntax
sys.dm_db_stats_properties (object_id, stats_id)
Arguments
object_id
Is the ID of the object in the current database for which properties of one of its statistics is requested. object_id is
int.
stats_id
Is the ID of statistics for the specified object_id. The statistics ID can be obtained from the sys.stats dynamic
management view. stats_id is int.
Table Returned
COLUMN NAME DATA TYPE DESCRIPTION
Remarks
sys.dm_db_stats_properties returns an empty rowset under any of the following conditions:
object_id or stats_id is NULL.
The specified object is not found or does not correspond to a table or indexed view.
The specified statistics ID does not correspond to existing statistics for the specified object ID.
The current user does not have permissions to view the statistics object.
This behavior allows for the safe usage of sys.dm_db_stats_properties when cross applied to rows in
views such as sys.objects and sys.stats.
Statistics update date is stored in the statistics blob object together with the histogram and density vector, not in
the metadata. When no data is read to generate statistics data, the statistics blob is not created, the date is not
available, and the last_updated column is NULL. This is the case for filtered statistics for which the predicate does
not return any rows, or for new empty tables.
Permissions
Requires that the user has select permissions on statistics columns or the user owns the table or the user is a
member of the sysadmin fixed server role, the db_owner fixed database role, or the db_ddladmin fixed database
role.
Examples
A. Simple example
The following example returns the statistics for the Person.Person table in the AdventureWorks database.
See Also
DBCC SHOW_STATISTICS (Transact-SQL )
sys.stats (Transact-SQL )
Object Related Dynamic Management Views and Functions (Transact-SQL )
Dynamic Management Views and Functions (Transact-SQL )
sys.dm_db_incremental_stats_properties (Transact-SQL )
sys.dm_db_stats_histogram (Transact-SQL )
sys.dm_sql_referenced_entities (Transact-SQL)
10/1/2018 • 10 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2008) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
Returns one row for each user-defined entity referenced by name in the definition of the specified referencing
entity in SQL Server. A dependency between two entities is created when one user-defined entity, called the
referenced entity, appears by name in a persisted SQL expression of another user-defined entity, called the
referencing entity. For example, if a stored procedure is the specified referencing entity, this function returns all
user-defined entities that are referenced in the stored procedure such as tables, views, user-defined types (UDTs),
or other stored procedures.
You can use this dynamic management function to report on the following types of entities referenced by the
specified referencing entity:
Schema-bound entities
Non-schema-bound entities
Cross-database and cross-server entities
Column-level dependencies on schema-bound and non-schema-bound entities
User-defined types (alias and CLR UDT)
XML schema collections
Partition functions
Applies to: SQL Server ( SQL Server 2008 through SQL Server 2017), SQL Database.
Syntax
sys.dm_sql_referenced_entities (
' [ schema_name. ] referencing_entity_name ' , ' <referencing_class> ' )
<referencing_class> ::=
{
OBJECT
| DATABASE_DDL_TRIGGER
| SERVER_DDL_TRIGGER
}
Arguments
[ schema_name. ] referencing_entity_name
Is the name of the referencing entity. schema_name is required when the referencing class is OBJECT.
schema_name.referencing_entity_name is nvarchar(517).
<referencing_class> ::= { OBJECT | DATABASE_DDL_TRIGGER | SERVER_DDL_TRIGGER }
Is the class of the specified referencing entity. Only one class can be specified per statement.
<referencing_class> is nvarchar(60).
Table Returned
COLUMN NAME DATA TYPE DESCRIPTION
1 = Object or column
6 = Type
21 = Partition function
COLUMN NAME DATA TYPE DESCRIPTION
OBJECT_OR_COLUMN
TYPE
XML_SCHEMA_COLLECTION
PARTITION_FUNCTION
1 = Reference to a user-defined
function or column user-defined type
(UDT) method is ambiguous.
Exceptions
Returns an empty result set under any of the following conditions:
A system object is specified.
The specified entity does not exist in the current database.
The specified entity does not reference any entities.
An invalid parameter is passed.
Returns an error when the specified referencing entity is a numbered stored procedure.
Returns error 2020 when column dependencies cannot be resolved. This error does not prevent the query
from returning object-level dependencies.
Remarks
This function can be executed in the context of the any database to return the entities that reference a server-level
DDL trigger.
The following table lists the types of entities for which dependency information is created and maintained.
Dependency information is not created or maintained for rules, defaults, temporary tables, temporary stored
procedures, or system objects.
Queue No Yes
Synonym No Yes
* A table is tracked as a referencing entity only when it references a Transact-SQL module, user-defined type, or
XML schema collection in the definition of a computed column, CHECK constraint, or DEFAULT constraint.
** Numbered stored procedures with an integer value greater than 1 are not tracked as either a referencing or
referenced entity.
Permissions
Requires SELECT permission on sys.dm_sql_referenced_entities and VIEW DEFINITION permission on the
referencing entity. By default, SELECT permission is granted to public. Requires VIEW DEFINITION permission on
the database or ALTER DATABASE DDL TRIGGER permission on the database when the referencing entity is a
database-level DDL trigger. Requires VIEW ANY DEFINITION permission on the server when the referencing
entity is a server-level DDL trigger.
Examples
A. Returning entities that are referenced by a database -level DDL trigger
The following example returns the entities (tables and columns) that are referenced by the database-level DDL
trigger ddlDatabaseTriggerLog .
USE AdventureWorks2012;
GO
SELECT referenced_schema_name, referenced_entity_name, referenced_minor_name,
referenced_minor_id, referenced_class_desc
FROM sys.dm_sql_referenced_entities ('ddlDatabaseTriggerLog', 'DATABASE_DDL_TRIGGER');
GO
USE AdventureWorks2012;
GO
SELECT referenced_schema_name, referenced_entity_name, referenced_minor_name,
referenced_minor_id, referenced_class_desc, is_caller_dependent, is_ambiguous
FROM sys.dm_sql_referenced_entities ('dbo.ufnGetContactInformation', 'OBJECT');
GO
USE AdventureWorks2012;
GO
CREATE TABLE dbo.Table1 (a int, b int, c AS a + b);
GO
SELECT referenced_schema_name AS schema_name,
referenced_entity_name AS table_name,
referenced_minor_name AS referenced_column,
COALESCE(COL_NAME(OBJECT_ID(N'dbo.Table1'),referencing_minor_id), 'N/A') AS referencing_column_name
FROM sys.dm_sql_referenced_entities ('dbo.Table1', 'OBJECT');
GO
USE AdventureWorks2012;
GO
IF OBJECT_ID ( 'dbo.Table1', 'U' ) IS NOT NULL
DROP TABLE dbo.Table1;
GO
CREATE TABLE dbo.Table2 (c1 int, c2 int);
GO
CREATE PROCEDURE dbo.Proc1 AS
SELECT a, b, c FROM Table1;
SELECT c1, c2 FROM Table2;
GO
SELECT referenced_id, referenced_entity_name AS table_name, referenced_minor_name AS referenced_column_name,
is_all_columns_found
FROM sys.dm_sql_referenced_entities ('dbo.Proc1', 'OBJECT');
GO
Msg 2020, Level 16, State 1, Line 1The dependencies reported for entity "dbo.Proc1" might not include
references to all columns. This is either because the entity references an object that does not exist or
because of an error in one or more statements in the entity. Before rerunning the query, ensure that there
are no errors in the entity and that all objects referenced by the entity exist.
USE AdventureWorks2012;
GO
CREATE TABLE Table1 (a int, b int, c AS a + b);
GO
SELECT referenced_id, referenced_entity_name AS table_name, referenced_minor_name as column_name,
is_all_columns_found
FROM sys.dm_sql_referenced_entities ('dbo.Proc1', 'OBJECT');
GO
DROP TABLE Table1, Table2;
DROP PROC Proc1;
GO
See Also
sys.dm_sql_referencing_entities (Transact-SQL )
sys.sql_expression_dependencies (Transact-SQL )
sys.dm_sql_referencing_entities (Transact-SQL)
10/1/2018 • 4 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2008) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
Returns one row for each entity in the current database that references another user-defined entity by name. A
dependency between two entities is created when one entity, called the referenced entity, appears by name in a
persisted SQL expression of another entity, called the referencing entity. For example, if a user-defined type (UDT)
is specified as the referenced entity, this function returns each user-defined entity that reference that type by name
in its definition. The function does not return entities in other databases that may reference the specified entity.
This function must be executed in the context of the master database to return a server-level DDL trigger as a
referencing entity.
You can use this dynamic management function to report on the following types of entities in the current database
that reference the specified entity:
Schema-bound or non-schema-bound entities
Database-level DDL triggers
Server-level DDL triggers
Applies to: SQL Server ( SQL Server 2008 through SQL Server 2017), SQL Database.
Transact-SQL Syntax Conventions
Syntax
sys.dm_sql_referencing_entities (
' schema_name.referenced_entity_name ' , ' <referenced_class> ' )
<referenced_class> ::=
{
OBJECT
| TYPE
| XML_SCHEMA_COLLECTION
| PARTITION_FUNCTION
}
Arguments
schema_name.referenced_entity_name
Is the name of the referenced entity.
schema_name is required except when the referenced class is PARTITION_FUNCTION.
schema_name.referenced_entity_name is nvarchar(517).
<referenced_class> ::= { OBJECT | TYPE | XML_SCHEMA_COLLECTION | PARTITION_FUNCTION }
Is the class of the referenced entity. Only one class can be specified per statement.
<referenced_class> is nvarchar(60).
Table Returned
COLUMN NAME DATA TYPE DESCRIPTION
1 = Object
OBJECT
DATABASE_DDL_TRIGGER
SERVER_DDL_TRIGGER
Exceptions
Returns an empty result set under any of the following conditions:
A system object is specified.
The specified entity does not exist in the current database.
The specified entity does not reference any entities.
An invalid parameter is passed.
Returns an error when the specified referenced entity is a numbered stored procedure.
Remarks
The following table lists the types of entities for which dependency information is created and maintained.
Dependency information is not created or maintained for rules, defaults, temporary tables, temporary stored
procedures, or system objects.
Queue No Yes
Synonym No Yes
* A table is tracked as a referencing entity only when it references a Transact-SQL module, user-defined type, or
XML schema collection in the definition of a computed column, CHECK constraint, or DEFAULT constraint.
** Numbered stored procedures with an integer value greater than 1 are not tracked as either a referencing or
referenced entity.
Permissions
SQL Server 2008 – SQL Server 2012 (11.x)
Requires CONTROL permission on the referenced object. When the referenced entity is a partition function,
CONTROL permission on the database is required.
Requires SELECT permission on sys.dm_sql_referencing_entities. By default, SELECT permission is granted
to public.
SQL Server 2014 (12.x) - SQL Server 2017
Requires no permissions on the referenced object. Partial results can be returned if the user has VIEW
DEFINITION on only some of the referencing entities.
Requires VIEW DEFINITION on the object when the referencing entity is an object.
Requires VIEW DEFINITION on the database when the referencing entity is a database-level DDL trigger.
Requires VIEW ANY DEFINITION on the server when the referencing entity is a server-level DDL trigger.
Examples
A. Returning the entities that refer to a given entity
The following example returns the entities in the current database that refer to the specified table.
USE AdventureWorks2012;
GO
SELECT referencing_schema_name, referencing_entity_name, referencing_id, referencing_class_desc,
is_caller_dependent
FROM sys.dm_sql_referencing_entities ('Production.Product', 'OBJECT');
GO
USE AdventureWorks2012;
GO
SELECT referencing_schema_name, referencing_entity_name, referencing_id, referencing_class_desc,
is_caller_dependent
FROM sys.dm_sql_referencing_entities ('dbo.Flag', 'TYPE');
GO
See Also
sys.dm_sql_referenced_entities (Transact-SQL )
sys.sql_expression_dependencies (Transact-SQL )
Query Notifications - sys.dm_qn_subscriptions
11/14/2018 • 3 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2008) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
Returns information about the active query notifications subscriptions in the server. You can use this view to check
for active subscriptions in the server or a specified database, or to check for a specified server principal.
id int ID of a subscription.
Relationship Cardinalities
FROM TO ON TYPE
66571 Subscription fired because database was object or user was dropped
detached or dropped
132610 Subscription creation failed because the Invalid statement for subscription
statement is not supported
132611 Subscription creation failed because the Invalid set options for subscription
statement is not supported
132623 Subscription creation failed because the over the template limit per table
statement is not supported
The following status codes are used internally and are classed as check kill and init modes:
198656 Used internally: check kill and init Undefined info mode
modes
Permissions
Requires VIEW SERVER STATE permission on server.
NOTE
If the user does not have VIEW SERVER STATE permission, this view returns information about subscriptions owned by
current user.
Examples
A. Return active query notification subscriptions for the current user
The following example returns the active query notification subscriptions of the current user. If the user has VIEW
SERVER STATE permissions, all active subscriptions in the server are returned.
See Also
Dynamic Management Views and Functions (Transact-SQL )
Query Notifications Related Dynamic Management Views (Transact-SQL )
KILL QUERY NOTIFICATION SUBSCRIPTION (Transact-SQL )
Replication Related Dynamic Management Views
(Transact-SQL)
10/1/2018 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2012) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
This section contains the following dynamic management objects used by replication.
sys.dm_repl_articles sys.dm_repl_schemas
sys.dm_repl_tranhash sys.dm_repl_traninfo
See Also
Dynamic Management Views and Functions (Transact-SQL )
sys.dm_repl_articles (Transact-SQL)
10/1/2018 • 3 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2008) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
Returns information about database objects published as articles in a replication topology.
1 = Article is active.
1 = Log-based article.
1 = CALL
2 = SQL
3 = NONE
7 = UNKNOWN
0 = XCALL
1 = CALL
2 = SQL
3 = NONE
7 = UNKNOWN
0 = XCALL
1 = CALL
2 = SQL
3 = NONE
4 = MCALL
5 = VCALL
6 = SCALL
7 = UNKNOWN
2 = SQL
1 = INSERT
2 = DELETE
3 = UPDATE
4 = UPDATETEXT
5 = none
8 = partial UPDATE
Permissions
Requires VIEW DATABASE STATE permission on the publication database to call dm_repl_articles.
Remarks
Information is only returned for replicated database objects that are currently loaded in the replication article
cache.
See Also
Dynamic Management Views and Functions (Transact-SQL )
Replication Related Dynamic Management Views (Transact-SQL )
sys.dm_repl_schemas (Transact-SQL)
10/1/2018 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2008) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
Returns information about table columns published by replication.
Permissions
Requires VIEW DATABASE STATE permission on the publication database to call dm_repl_schemas.
Remarks
Information is only returned for replicated database objects that are currently loaded in the replication article
cache.
See Also
Dynamic Management Views and Functions (Transact-SQL )
Replication Related Dynamic Management Views (Transact-SQL )
sys.dm_repl_tranhash (Transact-SQL)
10/1/2018 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2008) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
Returns information about transactions being replicated in a transactional publication.
Permissions
Requires VIEW DATABASE STATE permission on the publication database to call dm_repl_tranhash.
Remarks
Information is only returned for replicated database objects that are currently loaded in the replication article
cache.
See Also
Dynamic Management Views and Functions (Transact-SQL )
Replication Related Dynamic Management Views (Transact-SQL )
sys.dm_repl_traninfo (Transact-SQL)
11/14/2018 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2008) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
Returns information on each replicated or change data capture transaction.
Permissions
Requires VIEW DATABASE STATE permission on the publication database or on the database enabled for change
data capture.
Remarks
Information is only returned for replicated database objects or tables enabled for change data capture that are
currently loaded in the article cache.
See Also
Dynamic Management Views and Functions (Transact-SQL )
Replication Related Dynamic Management Views (Transact-SQL )
Change Data Capture Related Dynamic Management Views (Transact-SQL )
Resource Governor Related Dynamic Management
Views (Transact-SQL)
10/31/2018 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2008) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
This section contains the following dynamic management views for the Resource Governor.
sys.dm_resource_governor_external_resource_pools (Transact-
SQL)
See Also
Resource Governor Catalog Views (Transact-SQL )
Resource Governor
sys.dm_resource_governor_configuration (Transact-
SQL)
10/1/2018 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2008) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
Returns a row that contains the current in-memory configuration state of Resource Governor.
1 - A reconfiguration statement or
server restart is required in order for
pending configuration changes to be
applied.
Is not nullable.
Remarks
This dynamic management view shows the in-memory configuration. To see the stored configuration metadata,
use the corresponding catalog view.
The following example shows how to get and compare the stored metadata values and the in-memory values of
the Resource Governor configuration.
USE master;
go
-- Get the stored metadata.
SELECT
object_schema_name(classifier_function_id) AS 'Classifier UDF schema in metadata',
object_name(classifier_function_id) AS 'Classifier UDF name in metadata'
FROM
sys.resource_governor_configuration;
go
-- Get the in-memory configuration.
SELECT
object_schema_name(classifier_function_id) AS 'Active classifier UDF schema',
object_name(classifier_function_id) AS 'Active classifier UDF name'
FROM
sys.dm_resource_governor_configuration;
go
Permissions
Requires VIEW SERVER STATE permission.
See Also
Dynamic Management Views and Functions (Transact-SQL )
sys.resource_governor_configuration (Transact-SQL )
Resource Governor
sys.dm_resource_governor_external_resource_pool_affinity
(Transact-SQL)
10/1/2018 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2016) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
Applies to: SQL Server 2016 (13.x) R Services (In-Database) and SQL Server 2017 (14.x) Machine Learning
Services (In-Database)
Returns CPU affinity information about the current external resource pool configuration.
Remarks
Pools that are created with an affinity of AUTO do not appear in this view because they have no affinity. For more
information, see the CREATE EXTERNAL RESOURCE POOL (Transact-SQL ) and ALTER EXTERNAL RESOURCE
POOL (Transact-SQL ) statements.
Permissions
Requires VIEW SERVER STATE permission.
See also
Resource governance for machine learning in SQL Server
sys.dm_resource_governor_resource_pool_affinity (Transact-SQL )
external scripts enabled Server Configuration Option
ALTER EXTERNAL RESOURCE POOL (Transact-SQL )
sys.dm_resource_governor_external_resource_pools
(Transact-SQL)
10/1/2018 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2016) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
Returns information about the current external resource pool state, the current configuration of resource pools,
and resource pool statistics.
Transact-SQL Syntax Conventions.
Permissions
Requires VIEW SERVER STATE permission.
See Also
sys.dm_resource_governor_external_resource_pool_affinity (Transact-SQL )
sys.dm_resource_governor_resource_pool_affinity
(Transact-SQL)
10/1/2018 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2012) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
Tracks resource pool affinity.
Transact-SQL Syntax Conventions.
Remarks
Pools that are created with an affinity of AUTO will not appear in this view because they have no affinity. For more
information, see the CREATE RESOURCE POOL (Transact-SQL ) and ALTER RESOURCE POOL (Transact-SQL )
statements.
See Also
sys.dm_resource_governor_external_resource_pool_affinity (Transact-SQL )
sys.dm_resource_governor_resource_pools (Transact-
SQL)
10/1/2018 • 6 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2008) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
Returns information about the current resource pool state, the current configuration of resource pools, and
resource pool statistics.
NOTE
To call this from Azure SQL Data Warehouse or Parallel Data Warehouse, use the name
sys.dm_pdw_nodes_resource_governor_resource_pools.
Remarks
Resource Governor workload groups and Resource Governor resource pools have a many-to-one mapping. As a
result, many of the resource pool statistics are derived from the workload group statistics.
This dynamic management view shows the in-memory configuration. To see the stored configuration metadata,
use the sys.resource_governor_resource_pools catalog view.
Permissions
Requires VIEW SERVER STATE permission.
See Also
Dynamic Management Views and Functions (Transact-SQL )
sys.dm_resource_governor_workload_groups (Transact-SQL )
sys.resource_governor_resource_pools (Transact-SQL )
ALTER RESOURCE GOVERNOR (Transact-SQL )
sys.dm_resource_governor_resource_pool_volumes
(Transact-SQL)
10/1/2018 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2014) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
Returns information about the current resource pool IO statistics for each disk volume. This information is also
available at the resource pool level in sys.dm_resource_governor_resource_pools (Transact-SQL ).
Permissions
Requires VIEW SERVER STATE permission.
See also
Dynamic Management Views and Functions (Transact-SQL )
sys.dm_resource_governor_workload_groups (Transact-SQL )
sys.resource_governor_resource_pools (Transact-SQL )
ALTER RESOURCE GOVERNOR (Transact-SQL )
sys.dm_resource_governor_workload_groups
(Transact-SQL)
10/1/2018 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2008) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
Returns workload group statistics and the current in-memory configuration of the workload group. This view can
be joined with sys.dm_resource_governor_resource_pools to get the resource pool name.
NOTE
To call this from Azure SQL Data Warehouse or Parallel Data Warehouse, use the name
sys.dm_pdw_nodes_resource_governor_workload_groups.
Is not nullable.
Remarks
This dynamic management view shows the in-memory configuration. To see the stored configuration metadata,
use the sys.resource_governor_workload_groups catalog view.
When ALTER RESOURCE GOVERNOR RESET STATISTICS is successfully executed, the following counters are
reset: statistics_start_time, total_request_count, total_queued_request_count, total_cpu_limit_violation_count,
total_cpu_usage_ms, max_request_cpu_time_ms, total_lock_wait_count, total_lock_wait_time_ms,
total_query_optimization_count, total_suboptimal_plan_generation_count, total_reduced_memgrant_count, and
max_request_grant_memory_kb. statistics_start_time is set to the current system date and time, the other counters
are set to zero (0).
Permissions
Requires VIEW SERVER STATE permission.
See Also
Dynamic Management Views and Functions (Transact-SQL )
sys.dm_resource_governor_resource_pools (Transact-SQL )
sys.resource_governor_workload_groups (Transact-SQL )
ALTER RESOURCE GOVERNOR (Transact-SQL )
Security-Related Dynamic Management Views and
Functions (Transact-SQL)
10/1/2018 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2012) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
This section contains the following dynamic management objects:
See Also
Extensible Key Management (EKM )
Transparent Data Encryption (TDE )
SQL Server Audit (Database Engine)
sys.dm_audit_actions (Transact-SQL)
10/1/2018 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2008) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
Returns a row for every audit action that can be reported in the audit log and every audit action group that can be
configured as part of SQL Server Audit. For more information about SQL Server Audit, see SQL Server Audit
(Database Engine).
1 = Yes
0 = No
See Also
CREATE SERVER AUDIT (Transact-SQL )
ALTER SERVER AUDIT (Transact-SQL )
DROP SERVER AUDIT (Transact-SQL )
CREATE SERVER AUDIT SPECIFICATION (Transact-SQL )
ALTER SERVER AUDIT SPECIFICATION (Transact-SQL )
DROP SERVER AUDIT SPECIFICATION (Transact-SQL )
CREATE DATABASE AUDIT SPECIFICATION (Transact-SQL )
ALTER DATABASE AUDIT SPECIFICATION (Transact-SQL )
DROP DATABASE AUDIT SPECIFICATION (Transact-SQL )
ALTER AUTHORIZATION (Transact-SQL )
sys.fn_get_audit_file (Transact-SQL )
sys.server_audits (Transact-SQL )
sys.server_file_audits (Transact-SQL )
sys.server_audit_specifications (Transact-SQL )
sys.server_audit_specification_details (Transact-SQL )
sys.database_audit_specifications (Transact-SQL )
sys.database_audit_specification_details (Transact-SQL )
sys.dm_server_audit_status (Transact-SQL )
sys.dm_audit_class_type_map (Transact-SQL )
Create a Server Audit and Server Audit Specification
sys.dm_audit_class_type_map (Transact-SQL)
10/1/2018 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2008) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
Returns a table that maps the class_type field in the audit log to the class_desc field in sys.dm_audit_actions. For
more information about SQL Server Audit, see SQL Server Audit (Database Engine).
Permissions
Principal must have SELECT permission. By default, this is granted to Public.
See Also
CREATE SERVER AUDIT (Transact-SQL )
ALTER SERVER AUDIT (Transact-SQL )
DROP SERVER AUDIT (Transact-SQL )
CREATE SERVER AUDIT SPECIFICATION (Transact-SQL )
ALTER SERVER AUDIT SPECIFICATION (Transact-SQL )
DROP SERVER AUDIT SPECIFICATION (Transact-SQL )
CREATE DATABASE AUDIT SPECIFICATION (Transact-SQL )
ALTER DATABASE AUDIT SPECIFICATION (Transact-SQL )
DROP DATABASE AUDIT SPECIFICATION (Transact-SQL )
ALTER AUTHORIZATION (Transact-SQL )
sys.fn_get_audit_file (Transact-SQL )
sys.server_audits (Transact-SQL )
sys.server_file_audits (Transact-SQL )
sys.server_audit_specifications (Transact-SQL )
sys.server_audit_specification_details (Transact-SQL )
sys.database_audit_specifications (Transact-SQL )
sys.database_audit_specification_details (Transact-SQL )
sys.dm_server_audit_status (Transact-SQL )
sys.dm_audit_class_type_map
Create a Server Audit and Server Audit Specification
sys.dm_cryptographic_provider_algorithms (Transact-
SQL)
10/1/2018 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2008) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
Returns the algorithms supported by an Extensible Key Management (EKM ) provider.
Transact-SQL Syntax Conventions
Syntax
sys.dm_cryptographic_provider_algorithms ( provider_id )
Arguments
provider_id
Identification number of the EKM provider, with no default.
Tables Returned
COLUMN NAME DATA TYPE DESCRIPTION
Permissions
The user must be a member of the public database role.
Examples
The following example shows the provider options for a provider with the identification number of 1234567 .
See Also
Extensible Key Management (EKM )
Security-Related Dynamic Management Views and Functions (Transact-SQL )
sys.dm_cryptographic_provider_keys (Transact-SQL)
10/1/2018 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2008) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
Returns information about the keys provided by a Extensible Key Management (EKM ) provider.
Transact-SQL Syntax Conventions
Syntax
dm_cryptographic_provider_keys ( provider_id )
Arguments
provider_id
Identification number of the EKM provider, with no default.
Tables Returned
COLUMN NAME DATA TYPE DESCRIPTION
Permissions
When this view is queried it will authenticate the user context with the provider and enumerate all keys visible to
the user.
If the user cannot authenticate with the EKM provider, no key information will be returned.
Examples
The following example shows the key properties for a provider with the identification number of 1234567 .
See Also
Extensible Key Management (EKM )
sys.dm_cryptographic_provider_properties (Transact-
SQL)
10/1/2018 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2008) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
Returns information about registered cryptographic providers.
1 (supported)
1 (supported)
1 (supported)
1 (supported)
1 (supported)
1 (supported)
COLUMN NAME DATA TYPE DESCRIPTION
1 (supported)
1 (supported)
Remarks
The sys.dm_cryptographic_provider_properties view is visible to the public.
See Also
Security Catalog Views (Transact-SQL )
Encryption Hierarchy
Extensible Key Management (EKM )
CREATE CRYPTOGRAPHIC PROVIDER (Transact-SQL )
Security-Related Dynamic Management Views and Functions (Transact-SQL )
sys.dm_cryptographic_provider_sessions (Transact-
SQL)
10/1/2018 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2008) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
Returns information about open sessions for a cryptographic provider.
Syntax
sys.dm_cryptographic_provider_sessions(session_identifier)
Arguments
session_identifier
An integer indicating the sessions to be returned.
0 = Current connection only
1 = All cryptographic connections
Table Returned
COLUMN NAME DATA TYPE DESCRIPTION
Remarks
The sys.dm_cryptographic_provider_sessions view is visible to the public for the current connection. To view all
cryptographic connections, you must have the CONTROL server permission.
See Also
Security Catalog Views (Transact-SQL )
Extensible Key Management (EKM )
CREATE CRYPTOGRAPHIC PROVIDER (Transact-SQL )
Encryption Hierarchy
sys.dm_database_encryption_keys (Transact-SQL)
11/14/2018 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2008) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
Returns information about the encryption state of a database and its associated database encryption keys. For
more information about database encryption, see Transparent Data Encryption (TDE ).
1 = Unencrypted
2 = Encryption in progress
3 = Encrypted
5 = Decryption in progress
Permissions
On SQL Server, requires VIEW SERVER STATE permission.
On SQL Database, requires the VIEW DATABASE STATE permission in the database.
See Also
Security-Related Dynamic Management Views and Functions (Transact-SQL )
Transparent Data Encryption (TDE )
SQL Server Encryption
SQL Server and Database Encryption Keys (Database Engine)
Encryption Hierarchy
ALTER DATABASE SET Options (Transact-SQL )
CREATE DATABASE ENCRYPTION KEY (Transact-SQL )
ALTER DATABASE ENCRYPTION KEY (Transact-SQL )
DROP DATABASE ENCRYPTION KEY (Transact-SQL )
sys.dm_server_audit_status (Transact-SQL)
10/1/2018 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2008) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
Returns a row for each server audit indicating the current state of the audit. For more information, see SQL Server
Audit (Database Engine).
0 = Not Started
1=
Started
2=
Runtime Fail
4 = Shutting Down
NOT_STARTED
STARTED
RUNTIME_FAIL
TARGET_CREATION_FAILED
SHUTTING_DOWN
audit_file_path nvarchar(256) Full path and file name of the audit file
target that is currently being used. Only
populated for file audits.
COLUMN NAME DATA TYPE DESCRIPTION
Permissions
Principals must have VIEW SERVER STATE and SELECT permissions.
The visibility of the metadata in catalog views is limited to securables that a user either owns or on which the user
has been granted some permission. For more information, see Metadata Visibility Configuration.
See Also
CREATE SERVER AUDIT (Transact-SQL )
ALTER SERVER AUDIT (Transact-SQL )
DROP SERVER AUDIT (Transact-SQL )
CREATE SERVER AUDIT SPECIFICATION (Transact-SQL )
ALTER SERVER AUDIT SPECIFICATION (Transact-SQL )
DROP SERVER AUDIT SPECIFICATION (Transact-SQL )
CREATE DATABASE AUDIT SPECIFICATION (Transact-SQL )
ALTER DATABASE AUDIT SPECIFICATION (Transact-SQL )
DROP DATABASE AUDIT SPECIFICATION (Transact-SQL )
ALTER AUTHORIZATION (Transact-SQL )
sys.fn_get_audit_file (Transact-SQL )
sys.server_audits (Transact-SQL )
sys.server_file_audits (Transact-SQL )
sys.server_audit_specifications (Transact-SQL )
sys.server_audit_specification_details (Transact-SQL )
sys.database_audit_specifications (Transact-SQL )
sys.database_audit_specification_details (Transact-SQL )
sys.dm_server_audit_status
sys.dm_audit_actions (Transact-SQL )
sys.dm_audit_class_type_map (Transact-SQL )
Create a Server Audit and Server Audit Specification
Server-Related Dynamic Management Views and
Functions (Transact-SQL)
10/1/2018 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2012) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
This section contains the dynamic management views that are associated with the SQL Server, Full-text, and SQL
Server Agent services that are installed on the host server. You can use these views to return property information
for these services. These views also contain configuration, installation, and memory dump file information.
In This Section
sys.dm_server_memory_dumps sys.dm_server_services
sys.dm_server_registry
sys.dm_server_memory_dumps (Transact-SQL)
10/1/2018 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2008) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
Returns one row for each memory dump file generated by the SQL Server Database Engine. Use this dynamic
management view to troubleshoot potential issues.
General Remarks
The dump type may be a minidump, all-thread dump, or a full dump. The files have an extension of .mdmp.
Security
Dump files might contain sensitive information. To help protect sensitive information, you can use an access
control list (ACL ) to restrict access to the files, or copy the files to a folder that has restricted access. For example,
before you send your debug files to Microsoft support services, we recommend that you remove any sensitive or
confidential information.
Permissions
Requires VIEW SERVER STATE permission.
sys.dm_server_services (Transact-SQL)
10/10/2018 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2008) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
Returns information about the SQL Server, Full-Text, and SQL Server Agent services in the current instance of
SQL Server. Use this dynamic management view to report status information about these services.
0: Other
1: Other
2: Automatic
3: Manual
4: Disabled
Is nullable.
Cannot be null.
1: Stopped
2: Other (start pending)
3: Other (stop pending)
4: Running
5: Other (continue pending)
6: Other (pause pending)
7: Paused
Is nullable.
COLUMN NAME DATA TYPE DESCRIPTION
Cannot be null.
last_startup_time datetimeoffset(7) The date and time the service was last
started. Is nullable.
Is nullable.
Security
Permissions
Requires VIEW SERVER STATE permission on the server.
See Also
sys.dm_server_registry (Transact-SQL )
sys.dm_server_registry (Transact-SQL)
10/1/2018 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2008) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
Returns configuration and installation information that is stored in the Windows registry for the current instance
of SQL Server. Returns one row per registry key. Use this dynamic management view to return information such
as the SQL Server services that are available on the host machine or network configuration values for the instance
of SQL Server.
Security
Permissions
Requires VIEW SERVER STATE permission on the server.
Examples
A. Display the SQL Server services
The following example returns registry key values for the SQL Server and SQL Server Agent services for the
current instance of SQL Server.
D. Display the parameters passed to the instance of SQL Server during startup
The following example returns the parameters that are passed to the instance of SQL Server during startup.
See Also
sys.dm_server_services (Transact-SQL )
Service Broker Related Dynamic Management Views
(Transact-SQL)
11/14/2018 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2008) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
This section contains the following dynamic management views.
sys.dm_broker_activated_tasks sys.dm_broker_connections
sys.dm_broker_forwarded_messages sys.dm_broker_queue_monitors
See Also
Dynamic Management Views and Functions (Transact-SQL )
System Views (Transact-SQL )
sys.dm_broker_activated_tasks (Transact-SQL)
10/1/2018 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2008) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
Returns a row for each stored procedure activated by Service Broker.
Permissions
Requires VIEW SERVER STATE permission on the server.
Physical Joins
Relationship Cardinalities
FROM TO RELATIONSHIP
See Also
Dynamic Management Views and Functions (Transact-SQL )
Service Broker Related Dynamic Management Views (Transact-SQL )
sys.dm_broker_connections (Transact-SQL)
10/1/2018 • 4 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2008) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
Returns a row for each Service Broker network connection. The following table provides more information:
1 = NEW
2 = CONNECTING
3 = CONNECTED
4 = LOGGED_IN
5 = CLOSED
NEW
CONNECTING
CONNECTED
LOGGED_IN
CLOSED
0 = INITIAL
2 = ONE ISC
3 = ONE ASC
4 = TWO ISC
5 = TWO ASC
8 = WAIT REJECT
10 = WAIT VALIDATION
11 = WAIT ARBITRATION
12 = ONLINE
13 = ERROR
COLUMN NAME DATA TYPE DESCRIPTION
Connection is in error.
0 | none | Disabled
1 | SIGNING ONLY
NONE | Disabled
1 = True
1 = True
Permissions
Requires VIEW SERVER STATE permission on the server.
Physical Joins
Relationship Cardinalities
FROM TO RELATIONSHIP
See Also
Dynamic Management Views and Functions (Transact-SQL )
Service Broker Related Dynamic Management Views (Transact-SQL )
sys.dm_broker_forwarded_messages (Transact-SQL)
10/1/2018 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2008) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
Returns a row for each Service Broker message that an instance of SQL Server is in the process of forwarding.
1 = From initiator
Permissions
Requires VIEW SERVER STATE permission on the server.
See Also
Dynamic Management Views and Functions (Transact-SQL )
Service Broker Related Dynamic Management Views (Transact-SQL )
sys.dm_broker_queue_monitors (Transact-SQL)
10/1/2018 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2008) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
Returns a row for each queue monitor in the instance. A queue monitor manages activation for a queue.
INACTIVE
NOTIFIED
RECEIVES_OCCURRING
Permissions
Requires VIEW SERVER STATE permission on the server.
Examples
A. Current status queue monitor
This scenario provides the current status of all message queues.
See Also
Dynamic Management Views and Functions (Transact-SQL )
Service Broker Related Dynamic Management Views (Transact-SQL )
Spatial Data -
sys.dm_db_objects_disabled_on_compatibility_level_change
10/1/2018 • 3 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2012) Azure SQL Database Azure SQL Data Warehouse Parallel
Data Warehouse
Lists the indexes and constraints that will be disabled as a result of changing compatibility level in SQL Server. Indexes
and constraints that contain persisted computed columns whose expressions use spatial UDTs will be disabled after
upgrading or changing compatibility level. Use this dynamic management function to determine the impact of a
change in compatibility level.
Transact-SQL Syntax Conventions
Syntax
sys.dm_db_objects_disabled_on_compatibility_level_change ( compatibility_level )
Arguments
compatibility_level
int that identifies the compatibility level that you plan to set.
Table Returned
COLUMN NAME DATA TYPE DESCRIPTION
General Remarks
Persisted computed columns that use some intrinsic functions are disabled when the compatibility level is changed.
Also, persisted computed columns that use any Geometry or Geography method are disabled when a database is
upgraded.
Which functions cause persisted computed columns to be disabled?
When the following functions are used in the expression of a persisted computed column, they cause indexes and
constraints that reference those columns to be disabled when the compatibility level is changed from 80 to 90:
IsNumeric
When the following functions are used in the expression of a persisted computed column, they cause indexes
and constraints that reference those columns to be disabled when the compatibility level is changed from 100 to
110 or higher:
Soundex
Geography:: GeomFromGML
Geography:: STGeomFromText
Geography:: STLineFromText
Geography:: STPolyFromText
Geography:: STMPointFromText
Geography:: STMLineFromText
Geography:: STMPolyFromText
Geography:: STGeomCollFromText
Geography:: STGeomFromWKB
Geography:: STLineFromWKB
Geography:: STPolyFromWKB
Geography:: STMPointFromWKB
Geography:: STMLineFromWKB
Geography:: STMPolyFromWKB
Geography:: STUnion
Geography:: STIntersection
Geography:: STDifference
Geography:: STSymDifference
Geography:: STBuffer
Geography:: BufferWithTolerance
Geography:: Parse
Geography:: Reduce
Behavior of the disabled objects
Indexes
If the clustered index is disabled, or if a non-clustered index is forced, the following error is raised: "The query
processor is unable to produce a plan because the index '%.*ls' on table or view '%.*ls' is disabled." To re-enable these
objects, rebuild the indexes after upgrade by calling ALTER INDEX ON … REBUILD.
Heaps
If a table with a disabled heap is used, the following error is raised. To re-enable these objects, rebuild after upgrade by
calling ALTER INDEX ALL ON … REBUILD.
// ErrorNumber: 8674
// ErrorSeverity: EX_USER
// ErrorFormat: The query processor is unable to produce a plan because the table or view '%.*ls' is disabled.
// ErrorCause: The table has a disabled heap.
// ErrorCorrectiveAction: Rebuild the disabled heap to enable it.
// ErrorInserts: table or view name
// ErrorOwner: mtintor
// ErrorFirstProduct: SQL11
If you try to rebuild the heap during an online operation, an error is raised.
Check Constraints and Foreign Keys
Disabled check constraints and foreign keys do not raise an error. However, the constraints are not enforced when
rows are modified. To re-enable these objects, check the constraints after upgrading by calling ALTER TABLE …
CHECK CONSTRAINT.
Persisted Computed Columns
Since it is not possible to disable a single column, the entire table is disabled by disabling the clustered index or heap.
Security
Permissions
Requires the VIEW DATABASE STATE permission.
Example
The following example shows a query on sys.dm_db_objects_disabled_on_compatibility_level_change to find the
objects impacted by changing the compatibility level to 120.
APPLIES TO: SQL Server Azure SQL Database Azure SQL Data Warehouse Parallel Data
Warehouse
This topic lists the SQL Data Warehouse and Parallel Data Warehouse dynamic management views (DMVs).
All SQL Data Warehouse and Parallel Data Warehouse DMVs begin with sys.dm_pdw.
See Also
Dynamic Management Views and Functions (Transact-SQL )
sys.dm_pdw_component_health_active_alerts
(Transact-SQL)
10/1/2018 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server Azure SQL Database Azure SQL Data Warehouse Parallel Data
Warehouse
Stores active alerts on Parallel Data Warehouse components.
pdw_node_id, component_id,
component_instance_id,
alert_id, and
alert_instance_id form the
key for this view.
pdw_node_id, component_id,
component_instance_id,
alert_id, and
alert_instance_id form the
key for this view.
alert_id int The ID for the alert type. See NOT NULL
sys.pdw_health_alerts
(Transact-SQL).
pdw_node_id, component_id,
component_instance_id,
alert_id, and
alert_instance_id form the
key for this view.
pdw_node_id, component_id,
component_instance_id,
alert_id, and
alert_instance_id form the
key for this view.
COLUMN NAME DATA TYPE DESCRIPTION RANGE
For information about the maximum rows retained by this view, see "Minimum and Maximum Values" in the
Parallel Data Warehouse product documentation.
See Also
SQL Data Warehouse and Parallel Data Warehouse Dynamic Management Views (Transact-SQL )
sys.dm_pdw_component_health_alerts (Transact-SQL)
10/1/2018 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server Azure SQL Database Azure SQL Data Warehouse Parallel Data
Warehouse
Stores previously issued alerts on appliance components.
pdw_node_id, component_id,
component_instance_id,
alert_id, and
alert_instance_id form the
key for this view.
pdw_node_id, component_id,
component_instance_id,
alert_id, and
alert_instance_id form the
key for this view.
alert_id int The ID for the alert type. See NOT NULL
sys.pdw_health_alerts
(Transact-SQL).
pdw_node_id, component_id,
component_instance_id,
alert_id, and
alert_instance_id form the
key for this view.
pdw_node_id, component_id,
component_instance_id,
alert_id, and
alert_instance_id form the
key for this view.
COLUMN NAME DATA TYPE DESCRIPTION RANGE
See Also
SQL Data Warehouse and Parallel Data Warehouse Dynamic Management Views (Transact-SQL )
sys.dm_pdw_component_health_status (Transact-SQL)
10/1/2018 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server Azure SQL Database Azure SQL Data Warehouse Parallel Data
Warehouse
Holds information about the current health of appliance components.
pdw_node_id, component_id,
property_id, and
component_instance_id form
the key for this view.
pdw_node_id, component_id,
property_id, and
component_instance_id form
the key for this view.
update_time datetime The last time the metric was NOT NULL
updated.
See Also
SQL Data Warehouse and Parallel Data Warehouse Dynamic Management Views (Transact-SQL )
sys.dm_pdw_diag_processing_stats (Transact-SQL)
10/1/2018 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server Azure SQL Database Azure SQL Data Warehouse Parallel Data
Warehouse
Displays information related to all internal diagnostic events that could be incorporated into diagnostic sessions
defined by the administrator. Query this view to understand the statistics behind the diagnostics and eventing
subsystems that drive the population of all the other DMVs. There are a group of queues for each process on each
node.
See Also
SQL Data Warehouse and Parallel Data Warehouse Dynamic Management Views (Transact-SQL )
sys.dm_pdw_dms_cores (Transact-SQL)
11/14/2018 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server Azure SQL Database Azure SQL Data Warehouse Parallel Data
Warehouse
Holds information about all DMS services running on the Compute nodes of the appliance. It lists one row per
service instance, which is currently one row per node.
For information about the maximum rows retained by this view, see the Maximum System View Values section in
the Minimum and Maximum Values (SQL Server PDW ) topic.
See Also
SQL Data Warehouse and Parallel Data Warehouse Dynamic Management Views (Transact-SQL )
sys.dm_pdw_dms_external_work (Transact-SQL)
11/14/2018 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server Azure SQL Database Azure SQL Data Warehouse Parallel Data
Warehouse
SQL Data Warehouse system view that holds information about all Data Movement Service (DMS ) steps for
external operations.
input_name nvarchar(60) String name for the input For a Hadoop file, this is the
being read. Hadoop file name.
For information about the maximum rows retained by this view, see Maximum System View Values.
See Also
System Views (Transact-SQL )
sys.dm_pdw_dms_workers (Transact-SQL)
11/14/2018 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server Azure SQL Database Azure SQL Data Warehouse Parallel Data
Warehouse
Holds information about all workers completing DMS steps.
For information about the maximum rows retained by this view, see Maximum System View Values.
See Also
SQL Data Warehouse and Parallel Data Warehouse Dynamic Management Views (Transact-SQL )
sys.dm_pdw_errors (Transact-SQL)
11/14/2018 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server Azure SQL Database Azure SQL Data Warehouse Parallel Data
Warehouse
Holds information about all errors encountered during execution of a request or query.
error_id nvarchar(36) Key for this view. Unique across all query
errors in the system.
Unique numeric id
associated with the error.
For information about the maximum rows retained by this view, see the Maximum System View Values section in
the Minimum and Maximum Values (SQL Server PDW ) topic.
See Also
SQL Data Warehouse and Parallel Data Warehouse Dynamic Management Views (Transact-SQL )
sys.dm_pdw_exec_connections (Transact-SQL)
10/1/2018 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server Azure SQL Database Azure SQL Data Warehouse Parallel Data
Warehouse
Returns information about the connections established to this instance of SQL Data Warehouse and the details of
each connection.
Permissions
Requires VIEW SERVER STATE permission on the server.
Relationship Cardinalities
See Also
SQL Data Warehouse and Parallel Data Warehouse Dynamic Management Views (Transact-SQL )
sys.dm_pdw_exec_requests (Transact-SQL)
10/1/2018 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server Azure SQL Database Azure SQL Data Warehouse Parallel Data
Warehouse
Holds information about all requests currently or recently active in SQL Data Warehouse. It lists one row per
request/query.
request_id nvarchar(32) Key for this view. Unique Unique across all requests in
numeric id associated with the system.
the request.
start_time datetime Time at which the request NULL for queued requests;
execution was started. otherwise, valid datetime
smaller or equal to current
time.
end_compile_time datetime Time at which the engine NULL for requests that have
completed compiling the not been compiled yet;
request. otherwise a valid datetime
less than start_time and less
than or equal to the current
time.
end_time datetime Time at which the request Null for queued or active
execution completed, failed, requests; otherwise, a valid
or was cancelled. datetime smaller or equal
to current time.
COLUMN NAME DATA TYPE DESCRIPTION RANGE
If total_elapsed_time
exceeds the maximum value
for an integer,
total_elapsed_time will
continue to be the
maximum value. This
condition will generate the
warning “The maximum
value has been exceeded.”
command nvarchar(4000) Holds the full text of the Any valid query or request
request as submitted by the text. Queries that are longer
user. than 4000 bytes are
truncated.
XLargeRC
For information about the maximum rows retained by this view, see "Minimum and Maximum Values" in the
Parallel Data Warehouse product documentation.
Permissions
Requires VIEW SERVER STATE permission.
Security
sys.dm_pdw_exec_requests does not filter query results according to database-specific permissions. Logins with
VIEW SERVER STATE permission can obtain results query results for all databases
WARNING
An attacker can use sys.dm_pdw_exec_requests to retrieve information about specific database objects by simply having
VIEW SERVER STATE permission and by not having a database-specific permission.
See Also
SQL Data Warehouse and Parallel Data Warehouse Dynamic Management Views (Transact-SQL )
sys.dm_pdw_exec_sessions (Transact-SQL)
11/14/2018 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server Azure SQL Database Azure SQL Data Warehouse Parallel Data
Warehouse
Holds information about all sessions currently or recently open on the appliance. It lists one row per session.
session_id nvarchar(32) The id of the current query Unique across all sessions in
or the last query run (if the the system.
session is TERMINATED and
the query was executing at
time of termination). Key for
this view.
request_id nvarchar(32) The id of the current query Unique across all requests in
or last query run. the system. Null if none has
been run.
login_time datetime Date and time at which the Valid datetime before
user logged in and this current time.
session was created.
For information about the maximum rows retained by this view, see the Maximum System View Values section in
the Minimum and Maximum Values (SQL Server PDW ) topic.
Permissions
Requires the VIEW SERVER STATE permission.
See Also
SQL Data Warehouse and Parallel Data Warehouse Dynamic Management Views (Transact-SQL )
sys.dm_pdw_hadoop_operations (Transact-SQL)
11/14/2018 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server Azure SQL Database Azure SQL Data Warehouse Parallel Data
Warehouse
Contains a row for each map-reduce job that is pushed down to Hadoop as part of running a SQL Data
Warehouse query on an external Hadoop table. Each map-reduce job represents one of the predicates in the query.
This is only used when predicate pushdown is enabled for queries on Hadoop external tables.
See Also
System Views (Transact-SQL )
sys.dm_pdw_lock_waits (Transact-SQL)
10/1/2018 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server Azure SQL Database Azure SQL Data Warehouse Parallel Data
Warehouse
Holds information about the requests that are waiting for locks.
SharedUpdate
ExclusiveUpdate
Exclusive
DATABASE
SYSTEM
SCHEMA
APPLICATION
See Also
SQL Data Warehouse and Parallel Data Warehouse Dynamic Management Views (Transact-SQL )
sys.dm_pdw_network_credentials (Transact-SQL)
10/1/2018 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server Azure SQL Database Azure SQL Data Warehouse Parallel Data
Warehouse
Returns a list of all network credentials stored in the Parallel Data Warehouse appliance for all target servers.
Results are listed for the Control node, and every Compute node.
Permissions
Requires VIEW SERVER STATE.
General Remarks
The key for this dynamic management view is pdw_node_id plus target_server_name.
See Also
SQL Data Warehouse and Parallel Data Warehouse Dynamic Management Views (Transact-SQL )
sys.dm_pdw_node_status (Transact-SQL)
10/1/2018 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server Azure SQL Database Azure SQL Data Warehouse Parallel Data
Warehouse
Holds additional information (over sys.dm_pdw_nodes (Transact-SQL )) about the performance and status of all
appliance nodes. It lists one row per node in the appliance.
total_elapsed_time bigint Total time elapsed since Total time elapsed since
system start or restart. system start or restart. If
total_elapsed_time exceeds
the maximum value for an
integer (24.8 days in
milliseconds), it will cause
materialization failure due to
overflow.
See Also
SQL Data Warehouse and Parallel Data Warehouse Dynamic Management Views (Transact-SQL )
sys.dm_pdw_nodes (Transact-SQL)
10/1/2018 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server Azure SQL Database Azure SQL Data Warehouse Parallel Data
Warehouse
Holds information about all of the nodes in Analytics Platform System. It lists one row per node in the appliance.
See Also
SQL Data Warehouse and Parallel Data Warehouse Dynamic Management Views (Transact-SQL )
sys.dm_pdw_nodes_database_encryption_keys
(Transact-SQL)
11/14/2018 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server Azure SQL Database Azure SQL Data Warehouse Parallel Data
Warehouse
Returns information about the encryption state of a database and its associated database encryption keys.
sys.dm_pdw_nodes_database_encryption_keys provides this information for each node. For more information
about database encryption, see Transparent Data Encryption (SQL Server PDW ).
1 = Unencrypted
2 = Encryption in progress
3 = Encrypted
5 = Decryption in progress
Permissions
Requires the VIEW SERVER STATE permission on the server.
See Also
SQL Data Warehouse and Parallel Data Warehouse Dynamic Management Views (Transact-SQL )
CREATE DATABASE ENCRYPTION KEY (Transact-SQL )
ALTER DATABASE ENCRYPTION KEY (Transact-SQL )
DROP DATABASE ENCRYPTION KEY (Transact-SQL )
sys.dm_pdw_os_event_logs (Transact-SQL)
11/14/2018 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server Azure SQL Database Azure SQL Data Warehouse Parallel Data
Warehouse
Holds information regarding the different Windows Event logs on the different nodes.
For information about the maximum rows retained by this view, see the Maximum System View Values section in
the Minimum and Maximum Values (SQL Server PDW ) topic.
See Also
SQL Data Warehouse and Parallel Data Warehouse Dynamic Management Views (Transact-SQL )
sys.dm_pdw_os_performance_counters (Transact-SQL)
10/1/2018 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server Azure SQL Database Azure SQL Data Warehouse Parallel Data
Warehouse
Contains information about Windows performance counters for the nodes in Parallel Data Warehouse.
See Also
SQL Data Warehouse and Parallel Data Warehouse Dynamic Management Views (Transact-SQL )
sys.dm_pdw_os_threads (Transact-SQL)
10/1/2018 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server Azure SQL Database Azure SQL Data Warehouse Parallel Data
Warehouse
process_id int
name nvarchar(255)
priority int
start_time datetime
state nvarchar(32)
wait_reason nvarchar(32)
See Also
SQL Data Warehouse and Parallel Data Warehouse Dynamic Management Views (Transact-SQL )
sys.dm_pdw_query_stats_xe (Transact-SQL)
10/1/2018 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server Azure SQL Database Azure SQL Data Warehouse Parallel Data
Warehouse
This DMV is deprecated and will be removed in a future release. In this release, it returns 0 rows.
event_id nvarchar(36)
create_time datetime
cpu int
sql_text nvarchar(4000)
client_app_name nvarchar(255)
tsql_stack nvarchar(255)
See Also
SQL Data Warehouse and Parallel Data Warehouse Dynamic Management Views (Transact-SQL )
sys.dm_pdw_query_stats_xe_file (Transact-SQL)
10/1/2018 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server Azure SQL Database Azure SQL Data Warehouse Parallel Data
Warehouse
This DMV is deprecated and will be removed in a future release. In this release, it returns 0 rows.
data xml
See Also
SQL Data Warehouse and Parallel Data Warehouse Dynamic Management Views (Transact-SQL )
sys.dm_pdw_request_steps (Transact-SQL)
10/1/2018 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server Azure SQL Database Azure SQL Data Warehouse Parallel Data
Warehouse
Holds information about all steps that compose a given request or query in SQL Data Warehouse. It lists one
row per query step.
Unique numeric id
associated with the request.
If total_elapsed_time
exceeds the maximum value
for an integer,
total_elapsed_time will
continue to be the
maximum value. This
condition will generate the
warning “The maximum
value has been exceeded.”
row_count bigint Total number of rows 0 for steps that did not
changed or returned by this change or return data.
request. Otherwise, number of rows
affected.
command nvarchar(4000) Holds the full text of the Any valid request string for
command of this step. a step. NULL when the
operation is of the type
MetaDataCreateOperation.
Truncated if longer than
4000 characters.
For information about the maximum rows retained by this view, see the Maximum System View Values section in
the "Minimum and Maximum Values" in the Parallel Data Warehouse product documentation.
See Also
SQL Data Warehouse and Parallel Data Warehouse Dynamic Management Views (Transact-SQL )
sys.dm_pdw_resource_waits (Transact-SQL)
10/1/2018 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server Azure SQL Database Azure SQL Data Warehouse Parallel Data
Warehouse
Displays wait information for all resource types in SQL Data Warehouse.
Distributed Queries
Concurrency
DMS Concurrency
Backup Concurrency
DATABASE
SYSTEM
SCHEMA
APPLICATION
7 for LargeRC
22 – for XLargeRC
LargeRC
XLargeRC
See Also
SQL Data Warehouse and Parallel Data Warehouse Dynamic Management Views (Transact-SQL )
sys.dm_pdw_sql_requests (Transact-SQL)
11/14/2018 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server Azure SQL Database Azure SQL Data Warehouse Parallel Data
Warehouse
Holds information about all SQL Server query distributions as part of a SQL step in the query.
If total_elapsed_time exceeds
the maximum value for an
integer, total_elapsed_time
will continue to be the
maximum value. This
condition will generate the
warning “The maximum
value has been exceeded.”
command nvarchar(4000) Full text of command for this Any valid query or request
query distribution. string.
For information about the maximum rows retained by this view, see the Maximum System View Values section in
the Minimum and Maximum Values (SQL Server PDW ) topic.
See Also
SQL Data Warehouse and Parallel Data Warehouse Dynamic Management Views (Transact-SQL )
sys.dm_pdw_sys_info (Transact-SQL)
10/1/2018 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server Azure SQL Database Azure SQL Data Warehouse Parallel Data
Warehouse
Provides a set of appliance-level counters that reflect overall activity on the appliance.
See Also
SQL Data Warehouse and Parallel Data Warehouse Dynamic Management Views (Transact-SQL )
sys.dm_pdw_wait_stats (Transact-SQL)
11/14/2018 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server Azure SQL Database Azure SQL Data Warehouse Parallel Data
Warehouse
Holds information related to the SQL Server OS state related to instances running on the different nodes. For a list
of waits types and their description, see sys.dm_os_wait_stats.
See Also
SQL Data Warehouse and Parallel Data Warehouse Dynamic Management Views (Transact-SQL )
sys.dm_pdw_waits (Transact-SQL )
sys.dm_pdw_waits (Transact-SQL)
10/1/2018 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server Azure SQL Database Azure SQL Data Warehouse Parallel Data
Warehouse
Holds information about all wait states encountered during execution of a request or query, including locks, waits
on transmission queues, and so on.
See Also
SQL Data Warehouse and Parallel Data Warehouse Dynamic Management Views (Transact-SQL )
sys.dm_pdw_wait_stats (Transact-SQL )
SQL Server Operating System Related Dynamic
Management Views (Transact-SQL)
10/1/2018 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2008) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
This section contains the dynamic management views that are associated with the SQL Server Operating
System (SQLOS ). The SQLOS is responsible for managing operating system resources that are specific to SQL
Server.
sys.dm-os-job-object (Transact-SQL)
The following SQL Server Operating System–related dynamic management views are Identified for
informational purposes only. Not supported. Future compatibility is not guaranteed..
sys.dm_os_function_symbolic_name sys.dm_os_ring_buffers
sys.dm_os_memory_allocations sys.dm_os_sublatches
sys.dm_os_worker_local_storage
See Also
Dynamic Management Views and Functions (Transact-SQL )
sys.dm_os_buffer_descriptors (Transact-SQL)
10/1/2018 • 3 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2008) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
Returns information about all the data pages that are currently in the SQL Server buffer pool. The output of this
view can be used to determine the distribution of database pages in the buffer pool according to database, object,
or type. In SQL Server 2017, this dynamic management view also returns information about the data pages in the
buffer pool extension file. For more information, see Buffer Pool Extension.
When a data page is read from disk, the page is copied into the SQL Server buffer pool and cached for reuse. Each
cached data page has one buffer descriptor. Buffer descriptors uniquely identify each data page that is currently
cached in an instance of SQL Server. sys.dm_os_buffer_descriptors returns cached pages for all user and system
databases. This includes pages that are associated with the Resource database.
NOTE: To call this from Azure SQL Data Warehouse or Parallel Data Warehouse, use the name
sys.dm_pdw_nodes_os_buffer_descriptors.
Permissions
On SQL Server, requires VIEW SERVER STATE permission.
On SQL Database, requires the VIEW DATABASE STATE permission in the database.
Remarks
sys.dm_os_buffer_descriptors returns pages that are being used by the Resource database.
sys.dm_os_buffer_descriptors does not return information about free or stolen pages, or about pages that had
errors when they were read.
FROM TO ON RELATIONSHIP
Examples
A. Returning cached page count for each database
The following example returns the count of pages loaded for each database.
See Also
sys.allocation_units (Transact-SQL )
SQL Server Operating System Related Dynamic Management Views (Transact-SQL )
Resource Database
sys.dm_os_buffer_pool_extension_configuration (Transact-SQL )
sys.dm_os_buffer_pool_extension_configuration
(Transact-SQL)
10/1/2018 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2014) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
Returns configuration information about the buffer pool extension in SQL Server. Returns one row for each buffer
pool extension file.
Permissions
Requires VIEW SERVER STATE permission on the server.
Examples
A. Returning configuration buffer pool extension information
The following example returns all columns from the sys.dm_os_buffer_pool_extension_configruation DMV.
SELECT path, file_id, state, state_description, current_size_in_kb
FROM sys.dm_os_buffer_pool_extension_configuration;
B. Returning the number of cached pages in the buffer pool extension file
The following example returns the number of cached pages in each buffer pool extension file.
See Also
Buffer Pool Extension
sys.dm_os_buffer_descriptors (Transact-SQL )
sys.dm_os_child_instances (Transact-SQL)
11/14/2018 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2008) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
Returns a row for each user instance that has been created from the parent server instance.
IMPORTANT! This feature is in maintenance mode and may be removed in a future version of Microsoft SQL
Server. Avoid using this feature in new development work, and plan to modify applications that currently use
this feature.
The information returned from sys.dm_os_child_instances can be used to determine the state of each User
Instance (heart_beat) and to obtain the pipe name (instance_pipe_name) that can be used to create a connection to
the User Instance using SQL Server Management Studio or SQLCmd. You can only connect to a User Instance
after it has been started by an external process, such as a client application. SQL management tools cannot start a
User Instance.
NOTE: User Instances are a feature of SQL Server 2012 Express only.
NOTE To call this from Azure SQL Data Warehouse or Parallel Data Warehouse, use the name
sys.dm_pdw_nodes_os_child_instances.
Permissions
Requires VIEW SERVER STATE permission on the server.
Remarks
For more information about dynamic management view, see Dynamic Management Views and Functions
(Transact-SQL ) in SQL Server Books Online.
See Also
User Instances for Non-Administrators
sys.dm_os_cluster_nodes (Transact-SQL)
11/14/2018 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2008) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
Returns one row for each node in the failover cluster instance configuration. If the current instance is a failover
clustered instance, it returns a list of nodes on which this failover cluster instance (formerly "virtual server") has
been defined. If the current server instance is not a failover clustered instance, it returns an empty rowset.
NOTE: To call this from Azure SQL Data Warehouse or Parallel Data Warehouse, use the name
sys.dm_pdw_nodes_os_cluster_nodes.
0 = up
1 = down
2 = paused
3 = joining
-1 = unknown
Remarks
When failover clustering is enabled, the SQL Server instance can run on any of the nodes of the failover cluster
that are designated as part of the SQL Server failover cluster instance (virtual server) configuration.
NOTE: This view replaces the fn_virtualservernodes function, which will be deprecated in a future release.
Permissions
Requires VIEW SERVER STATE permission on the instance of SQL Server.
Examples
The following example uses sys. dm_os_cluster_nodes to return the nodes on a clustered server instance.
node1 0 up 1
node2 0 up 0
Node3 1 down 0
See Also
sys.dm_os_cluster_properties (Transact-SQL )
sys.dm_io_cluster_shared_drives (Transact-SQL )
sys.fn_virtualservernodes (Transact-SQL )
Dynamic Management Views and Functions (Transact-SQL )
sys.dm_os_cluster_properties (Transact-SQL)
10/1/2018 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2012) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
Returns one row with the current settings for the SQL Server cluster resource properties identified in this topic. No
data is returned if this view is run on a stand-alone instance of SQL Server.
These properties are used to set the values that affect failure detection, failure response time, and the logging for
monitoring the health status of the SQL Server failover cluster instance.
1 - Errors only
Permissions
Requires VIEW SERVER STATE permissions on the SQL Server failover cluster instance.
Examples
The following example uses sys.dm_os_cluster_properties to return the property settings for the SQL Server
failover cluster resource.
0 0 NULL 0 3 60000
sys.dm_os_dispatcher_pools (Transact-SQL)
10/1/2018 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2008) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
Returns information about session dispatcher pools. Dispatcher pools are thread pools used by system
components to perform background processing.
NOTE
To call this from Azure SQL Data Warehouse or Parallel Data Warehouse, use the name
sys.dm_pdw_nodes_os_dispatcher_pools.
DISP_POOL_XE_ENGINE
DISP_POOL_XE_SESSION
Permissions
On SQL Server, requires VIEW SERVER STATE permission.
On SQL Database, requires the VIEW DATABASE STATE permission in the database.
See Also
sys.dm_os_host_info (Transact-SQL)
11/14/2018 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2017) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
Returns one row that displays operating system version information.
Remarks
This view is similar to sys.dm_os_windows_info, adding columns to differentiate Windows and Linux.
Security
Permissions
The SELECT permission on sys.dm_os_host_info is granted to the public role by default. If revoked, requires
VIEW SERVER STATE permission on the server.
Cau t i on
Beginning with version SQL Server 2017 (14.x) CTP 1.3, SQL Server Management Studio version 17 requires
SELECT permission on sys.dm_os_host_info in order to connect to SQL Server. If SELECT permission is revoked
from public , only logins with VIEW SERVER STATE permission can connect with the newest version of SSMS.
(Other tools, such as sqlcmd.exe can connect without SELECT permission on sys.dm_os_host_info .)
Examples
The following example returns all columns from the sys.dm_os_host_info view.
See Also
sys.dm_os_sys_info (Transact-SQL )
sys.dm_os_windows_info (Transact-SQL )
sys.dm_os_hosts (Transact-SQL)
10/1/2018 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2008) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
Returns all the hosts currently registered in an instance of SQL Server. This view also returns the resources that
are used by these hosts.
NOTE
To call this from Azure SQL Data Warehouse or Parallel Data Warehouse, use the name sys.dm_pdw_nodes_os_hosts.
SOSHOST_CLIENTID_SERVERSNI= SQL
Server Native Interface
SOSHOST_CLIENTID_SQLOLEDB = SQL
Server Native Client OLE DB Provider
SOSHOST_CLIENTID_MSDART =
Microsoft Data Access Run Time
Permissions
On SQL Server, requires VIEW SERVER STATE permission.
On SQL Database, requires the VIEW DATABASE STATE permission in the database.
Remarks
SQL Server allows components, such as an OLE DB provider, that are not part of the SQL Server executable to
allocate memory and participate in non-preemptive scheduling. These components are hosted by SQL Server, and
all resources allocated by these components are tracked. Hosting allows SQL Server to better account for
resources used by components external to the SQL Server executable.
Relationship Cardinalities
FROM TO RELATIONSHIP
Examples
The following example determines the total amount of memory committed by a hosted component.
||
|-|
|Applies to: SQL Server 2012 (11.x) through SQL Server 2017.|
See Also
sys.dm_os_memory_clerks (Transact-SQL )
SQL Server Operating System Related Dynamic Management Views (Transact-SQL )
sys.dm_os_job_object (Azure SQL Database)
10/1/2018 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server Azure SQL Database Azure SQL Data Warehouse Parallel Data
Warehouse
Returns a single row describing the configuration of the job object that manages the SQL Server process, as well
as certain resource consumption statistics at the job object level. Returns an empty set if SQL Server is not running
in a job object.
A job object is a Windows construct that implements CPU, memory, and IO resource governance at the operating
system level. For more information about job objects, see Job Objects.
Permissions
On SQL Database Managed Instance, requires VIEW SERVER STATE permission. On SQL Database, requires the
VIEW DATABASE STATE permission in the database.
See Also
For information on Managed Instances, see SQL Database Managed Instance.
sys.dm_os_latch_stats (Transact-SQL)
10/1/2018 • 6 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2008) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
Returns information about all latch waits organized by class.
NOTE
To call this from Azure SQL Data Warehouse or Parallel Data Warehouse, use the name sys.dm_pdw_nodes_os_latch_stats.
Permissions
On SQL Server, requires VIEW SERVER STATE permission.
On SQL Database, requires the VIEW DATABASE STATE permission in the database.
Remarks
sys.dm_os_latch_stats can be used to identify the source of latch contention by examining the relative wait
numbers and wait times for the different latch classes. In some situations, you may be able to resolve or reduce
latch contention. However, there might be situations that will require that you to contact Microsoft Customer
Support Services.
You can reset the contents of sys.dm_os_latch_stats by using DBCC SQLPERF as follows:
DBCC SQLPERF ('sys.dm_os_latch_stats', CLEAR);
GO
NOTE
These statistics are not persisted if SQL Server is restarted. All data is cumulative since the last time the statistics were reset,
or since SQL Server was started.
Latches
A latch is a lightweight synchronization object that is used by various SQL Server components. A latch is primarily
used to synchronize database pages. Each latch is associated with a single allocation unit.
A latch wait occurs when a latch request cannot be granted immediately, because the latch is held by another
thread in a conflicting mode. Unlike locks, a latch is released immediately after the operation, even in write
operations.
Latches are grouped into classes based on components and usage. Zero or more latches of a particular class can
exist at any point in time in an instance of SQL Server.
NOTE
sys.dm_os_latch_stats does not track latch requests that were granted immediately, or that failed without waiting.
The following table contains brief descriptions of the various latch classes.
See Also
DBCC SQLPERF (Transact-SQL )
SQL Server Operating System Related Dynamic Management Views (Transact-SQL )
sys.dm_os_loaded_modules (Transact-SQL)
10/1/2018 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2008) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
Returns a row for each module loaded into the server address space.
NOTE
To call this from Parallel Data Warehouse, use the name sys.dm_pdw_nodes_os_loaded_modules.
x.x:x.x
x.x:x.x
Permissions
Requires VIEW SERVER STATE permission on the server.
See Also
Dynamic Management Views and Functions (Transact-SQL )
SQL Server Operating System Related Dynamic Management Views (Transact-SQL )
sys.dm_os_memory_brokers (Transact-SQL)
10/9/2018 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2008) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
Allocations that are internal to SQL Server use the SQL Server memory manager. Tracking the difference between
process memory counters from sys.dm_os_process_memory and internal counters can indicate memory use
from external components in the SQL Server memory space.
Memory brokers fairly distribute memory allocations between various components within SQL Server, based on
current and projected usage. Memory brokers do not perform allocations. They only track allocations for
computing distribution.
The following table provides information about memory brokers.
NOTE
To call this from Azure SQL Data Warehouse or Parallel Data Warehouse, use the name
sys.dm_pdw_nodes_os_memory_brokers.
MEMORYBROKER_FOR_CACHE :
Memory that is allocated for use by
cached objects (Not Buffer Pool cache).
MEMORYBROKER_FOR_STEAL :
Memory that is stolen from the buffer
pool. This memory is not available for
reuse by other components until it is
freed by the current owner.
MEMORYBROKER_FOR_RESERVE :
Memory reserved for future use by
currently executing requests.
grow
shrink
stable
Permissions
On SQL Server, requires VIEW SERVER STATE permission.
On SQL Database, requires the VIEW DATABASE STATE permission in the database.
See Also
SQL Server Operating System Related Dynamic Management Views (Transact-SQL )
sys.dm_os_memory_cache_clock_hands (Transact-
SQL)
10/1/2018 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2008) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
Returns the status of each hand for a specific cache clock.
NOTE
To call this from Azure SQL Data Warehouse or Parallel Data Warehouse, use the name
sys.dm_pdw_nodes_os_memory_cache_clock_hands.
External
Internal
Is not nullable.
Suspended
Running
Is not nullable.
Permissions
On SQL Server, requires VIEW SERVER STATE permission.
On SQL Database, requires the VIEW DATABASE STATE permission in the database.
Remarks
SQL Server stores information in memory in a structure called a memory cache. The information in the cache can
be data, index entries, compiled procedure plans, and a variety of other types of SQL Server information. To avoid
re-creating the information, it is retained the memory cache as long as possible and is ordinarily removed from the
cache when it is too old to be useful, or when the memory space is needed for new information. The process that
removes old information is called a memory sweep. The memory sweep is a frequent activity, but is not
continuous. A clock algorithm controls the sweep of the memory cache. Each clock can control several memory
sweeps, which are called hands. The memory-cache clock hand is the current location of one of the hands of a
memory sweep.
See Also
SQL Server Operating System Related Dynamic Management Views (Transact-SQL )
sys.dm_os_memory_cache_counters (Transact-SQL )
sys.dm_os_memory_cache_counters (Transact-SQL)
10/1/2018 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2008) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
Returns a snapshot of the health of a cache in SQL Server. sys.dm_os_memory_cache_counters provides run-
time information about the cache entries allocated, their use, and the source of memory for the cache entries.
NOTE: To call this from Azure SQL Data Warehouse or Parallel Data Warehouse, use the name
sys.dm_pdw_nodes_os_memory_cache_counters.
Permissions
On SQL Server, requires VIEW SERVER STATE permission.
On SQL Database, requires the VIEW DATABASE STATE permission in the database.
See Also
SQL Server Operating System Related Dynamic Management Views (Transact-SQL )
sys.dm_os_memory_cache_entries (Transact-SQL)
10/1/2018 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2008) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
Returns information about all entries in caches in SQL Server. Use this view to trace cache entries to their
associated objects. You can also use this view to obtain statistics on cache entries.
NOTE
To call this from Azure SQL Data Warehouse or Parallel Data Warehouse, use the name
sys.dm_pdw_nodes_os_memory_cache_entries.
Is not nullable.
not katmai
Permissions
On SQL Server, requires VIEW SERVER STATE permission.
On SQL Database, requires the VIEW DATABASE STATE permission in the database.
See Also
SQL Server Operating System Related Dynamic Management Views (Transact-SQL )
sys.dm_os_memory_cache_hash_tables (Transact-SQL)
10/1/2018 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2008) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
Returns a row for each active cache in the instance of SQL Server.
NOTE
To call this from Azure SQL Data Warehouse or Parallel Data Warehouse, use the name
sys.dm_pdw_nodes_os_memory_cache_hash_tables.
Permissions
On SQL Server, requires VIEW SERVER STATE permission.
On SQL Database, requires the VIEW DATABASE STATE permission in the database.
See Also
SQL Server Operating System Related Dynamic Management Views (Transact-SQL )
sys.dm_os_memory_clerks (Transact-SQL)
10/1/2018 • 3 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2008) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
Returns the set of all memory clerks that are currently active in the instance of SQL Server.
NOTE
To call this from Azure SQL Data Warehouse or Parallel Data Warehouse, use the name
sys.dm_pdw_nodes_os_memory_clerks.
Is not nullable.
Permissions
On SQL Server, requires VIEW SERVER STATE permission.
On SQL Database, requires the VIEW DATABASE STATE permission in the database.
Remarks
The SQL Server memory manager consists of a three-layer hierarchy. At the bottom of the hierarchy are
memory nodes. The middle level consists of memory clerks, memory caches, and memory pools. The top layer
consists of memory objects. These objects are generally used to allocate memory in an instance of SQL Server.
Memory nodes provide the interface and the implementation for low -level allocators. Inside SQL Server, only
memory clerks have access to memory nodes. Memory clerks access memory node interfaces to allocate
memory. Memory nodes also track the memory allocated by using the clerk for diagnostics. Every component
that allocates a significant amount of memory must create its own memory clerk and allocate all its memory by
using the clerk interfaces. Frequently, components create their corresponding clerks at the time SQL Server is
started.
See Also
SQL Server Operating System Related Dynamic Management Views (Transact-SQL )
sys.dm_os_sys_info (Transact-SQL )
sys.dm_exec_query_memory_grants (Transact-SQL )
sys.dm_exec_requests (Transact-SQL )
sys.dm_exec_query_plan (Transact-SQL )
sys.dm_exec_sql_text (Transact-SQL )
sys.dm_os_memory_nodes (Transact-SQL)
10/1/2018 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2008) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
Allocations that are internal to SQL Server use the SQL Server memory manager. Tracking the difference between
process memory counters from sys.dm_os_process_memory and internal counters can indicate memory use
from external components in the SQL Server memory space.
Nodes are created per physical NUMA memory nodes. These might be different from the CPU nodes in
sys.dm_os_nodes.
No allocations done directly through Windows memory allocations routines are tracked. The following table
provides information about memory allocations done only by using SQL Server memory manager interfaces.
NOTE
To call this from Azure SQL Data Warehouse or Parallel Data Warehouse, use the name
sys.dm_pdw_nodes_os_memory_nodes.
Permissions
On SQL Server, requires VIEW SERVER STATE permission.
On SQL Database, requires the VIEW DATABASE STATE permission in the database.
See Also
SQL Server Operating System Related Dynamic Management Views (Transact-SQL )
sys.dm_os_memory_objects (Transact-SQL)
10/1/2018 • 3 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2008) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
Returns memory objects that are currently allocated by SQL Server. You can use sys.dm_os_memory_objects to
analyze memory use and to identify possible memory leaks.
Permissions
On SQL Server, requires VIEW SERVER STATE permission.
On SQL Database, requires the VIEW DATABASE STATE permission in the database.
Remarks
Memory objects are heaps. They provide allocations that have a finer granularity than those provided by memory
clerks. SQL Server components use memory objects instead of memory clerks. Memory objects use the page
allocator interface of the memory clerk to allocate pages. Memory objects do not use virtual or shared memory
interfaces. Depending on the allocation patterns, components can create different types of memory objects to
allocate regions of arbitrary size.
The typical page size for a memory object is 8 KB. However, incremental memory objects can have page sizes that
range from 512 bytes to 8 KB.
NOTE
Page size is not a maximum allocation. Instead, page size is allocation granularity that is supported by a page allocator and
that is implemented by a memory clerk. You can request allocations greater than 8 KB from memory objects.
Examples
The following example returns the amount of memory allocated by each memory object type.
See Also
SQL Server Operating System Related Dynamic Management Views (Transact-SQL )
sys.dm_os_memory_clerks (Transact-SQL )
sys.dm_os_memory_pools (Transact-SQL)
10/1/2018 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2008) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
Returns a row for each object store in the instance of SQL Server. You can use this view to monitor cache memory
use and to identify bad caching behavior
NOTE
To call this from Azure SQL Data Warehouse or Parallel Data Warehouse, use the name
sys.dm_pdw_nodes_os_memory_pools.
Permissions
On SQL Server, requires VIEW SERVER STATE permission.
On SQL Database, requires the VIEW DATABASE STATE permission in the database.
Remarks
SQL Server components sometimes use a common pool framework to cache homogeneous, stateless types of
data. The pool framework is simpler than cache framework. All entries in the pools are considered equal. Internally,
pools are memory clerks and can be used in places where memory clerks are used.
See Also
SQL Server Operating System Related Dynamic Management Views (Transact-SQL )
sys.dm_os_nodes (Transact-SQL)
10/1/2018 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2008) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
An internal component named the SQLOS creates node structures that mimic hardware processor locality. These
structures can be changed by using soft-NUMA to create custom node layouts.
NOTE
Starting with SQL Server 2016 (13.x), the SQL Server Database Engine will automatically use soft-NUMA for certain hardware
configurations. For more information, see Automatic Soft-NUMA.
NOTE
To call this DMV from Azure SQL Data Warehouse or Parallel Data Warehouse, use the name
sys.dm_pdw_nodes_os_nodes.
Permissions
On SQL Server, requires VIEW SERVER STATE permission.
On SQL Database, requires the VIEW DATABASE STATE permission in the database.
See Also
SQL Server Operating System Related Dynamic Management Views (Transact-SQL )
Soft-NUMA (SQL Server)
sys.dm_os_performance_counters (Transact-SQL)
11/14/2018 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2008) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
Returns a row per performance counter maintained by the server. For information about each performance
counter, see Use SQL Server Objects.
NOTE
To call this from Azure SQL Data Warehouse or Parallel Data Warehouse, use the name
sys.dm_pdw_nodes_os_performance_counters.
Remarks
If the installation instance of SQL Server fails to display the performance counters of the Windows operating
system, use the following Transact-SQL query to confirm that performance counters have been disabled.
If the return value is 0 rows, this means that the performance counters have been disabled. You should then look at
the setup log and search for error 3409, "Reinstall sqlctr.ini for this instance, and ensure that the instance login
account has correct registry permissions." This denotes that performance counters were not enabled. The errors
immediately before the 3409 error should indicate the root cause for the failure of performance counter enabling.
For more information about setup log files, see View and Read SQL Server Setup Log Files.
Permission
On SQL Server, requires VIEW SERVER STATE permission.
On SQL Database, requires the VIEW DATABASE STATE permission in the database.
Examples
The following example returns performance counter values.
See Also
SQL Server Operating System Related Dynamic Management Views (Transact-SQL )
sys.sysperfinfo (Transact-SQL )
sys.dm_os_process_memory (Transact-SQL)
10/1/2018 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2008) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
Most memory allocations that are attributed to the SQL Server process space are controlled through interfaces
that allow for tracking and accounting of those allocations. However, memory allocations might be performed in
the SQL Server address space that bypasses internal memory management routines. Values are obtained through
calls to the base operating system. They are not manipulated by methods internal to SQL Server, except when it
adjusts for locked or large page allocations.
All returned values that indicate memory sizes are shown in kilobytes (KB ). The column
total_virtual_address_space_reserved_kb is a duplicate of virtual_memory_in_bytes from
sys.dm_os_sys_info.
The following table provides a complete picture of the process address space.
NOTE
To call this from Azure SQL Data Warehouse or Parallel Data Warehouse, use the name
sys.dm_pdw_nodes_os_process_memory.
Permissions
On SQL Server requires VIEW SERVER STATE permission on the server.
On SQL Server, requires VIEW SERVER STATE permission.
On SQL Database, requires the VIEW DATABASE STATE permission in the database.
See Also
Dynamic Management Views and Functions (Transact-SQL )
SQL Server Operating System Related Dynamic Management Views (Transact-SQL )
sys.dm_os_schedulers (Transact-SQL)
10/1/2018 • 8 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2008) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
Returns one row per scheduler in SQL Server where each scheduler is mapped to an individual processor. Use this
view to monitor the condition of a scheduler or to identify runaway tasks.
NOTE
To call this from Azure SQL Data Warehouse or Parallel Data Warehouse, use the name sys.dm_pdw_nodes_os_schedulers.
Is not nullable.
- HIDDEN ONLINE
- HIDDEN OFFLINE
- VISIBLE ONLINE
- VISIBLE OFFLINE
- VISIBLE ONLINE (DAC)
- HOT_ADDED
Is not nullable.
Is not nullable.
Permissions
On SQL Server, requires VIEW SERVER STATE permission.
On SQL Database, requires the VIEW DATABASE STATE permission in the database.
Examples
A. Monitoring hidden and nonhidden schedulers
The following query outputs the state of workers and tasks in SQL Server across all schedulers. This query was
executed on a computer system that has the following:
Two processors (CPUs)
Two (NUMA) nodes
One CPU per NUMA node
Affinity mask set to 0x03 .
SELECT
scheduler_id,
cpu_id,
parent_node_id,
current_tasks_count,
runnable_tasks_count,
current_workers_count,
active_workers_count,
work_queue_count
FROM sys.dm_os_schedulers;
runnable_tasks_count current_workers_count
-------------------- ---------------------
0 11
0 1
0 18
0 1
0 3
active_workers_count work_queue_count
-------------------- --------------------
6 0
1 0
8 0
1 0
1 0
SELECT
scheduler_id,
cpu_id,
current_tasks_count,
runnable_tasks_count,
current_workers_count,
active_workers_count,
work_queue_count
FROM sys.dm_os_schedulers
WHERE scheduler_id < 255;
By comparison, the following result shows multiple runnable tasks where no task is waiting to obtain a worker.
The work_queue_count is 0 for both schedulers.
See Also
SQL Server Operating System Related Dynamic Management Views (Transact-SQL )
sys.dm_os_server_diagnostics_log_configurations
10/1/2018 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2012) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
Returns one row with the current configuration for the SQL Server failover cluster diagnostic log. These property
settings determine whether the diagnostic logging is on or off, and the location, number, and size of the log files.
Permissions
Requires VIEW SERVER STATE permissions on the SQL Server failover cluster instance.
Examples
The following example uses sys.dm_os_server_diagnostics_log_configurations to return the property settings for
the SQL Server failover diagnostic logs.
1 <C:\Program Files\Microsoft 10 10
SQL
Server\MSSQL13\MSSQL\Lo
g>
See Also
View and Read Failover Cluster Instance Diagnostics Log
sys.dm_os_stacks (Transact-SQL)
10/1/2018 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2008) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
This dynamic management view is used internally by SQL Server to do the following:
Keep track of debug data such as outstanding allocations.
Assume or validate logic that is used by SQL Server components in places where the component assumes
that a certain call has been made.
Remarks
sys.dm_os_stacks requires that the symbols of the server and other components be present on the server to
display the information correctly.
Permissions
On SQL Server, requires VIEW SERVER STATE permission.
On SQL Database, requires the VIEW DATABASE STATE permission in the database.
See Also
SQL Server Operating System Related Dynamic Management Views (Transact-SQL )
sys.dm_os_sys_info (Transact-SQL)
11/14/2018 • 7 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2008) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
Returns a miscellaneous set of useful information about the computer, and about the resources available to and
consumed by SQL Server.
NOTE: To call this from Azure SQL Data Warehouse or Parallel Data Warehouse, use the name
sys.dm_pdw_nodes_os_sys_info.
- configuration parameters
1 = MANUAL
2 = AUTO
0 = QUERY_PERFORMANCE_COUNTER
1 = MULTIMEDIA_TIMER
DESCRIPTION AND VERSION-SPECIFIC
COLUMN NAME DATA TYPE NOTES
QUERY_PERFORMANCE_COUNTER =
the QueryPerformanceCounter API
retrieves wall clock time.
0 = NONE
1 = HYPERVISOR
2 = OTHER
1 = Automated soft-NUMA
See Also
Dynamic Management Views and Functions (Transact-SQL )
SQL Server Operating System Related Dynamic Management Views (Transact-SQL )
sys.dm_os_sys_memory (Transact-SQL)
11/14/2018 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2008) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
Returns memory information from the operating system.
SQL Server is bounded by, and responds to, external memory conditions at the operating system level and the
physical limits of the underlying hardware. Determining the overall system state is an important part of evaluating
SQL Server memory usage.
NOTE
To call this from Azure SQL Data Warehouse or Parallel Data Warehouse, use the name
sys.dm_pdw_nodes_os_sys_memory.
CONDITION VALUE
and
system_low_memory_signal_state = 0
and
system_low_memory_signal_state = 1
and
system_low_memory_signal_state = 0
and The high and low signal should never be on at the same time.
However, rapid changes at the operating system level can
system_low_memory_signal_state = 1 cause both values to appear to be on to a user mode
application. The appearance of both signals being on will be
interpreted as a transition state.
Permissions
Requires VIEW SERVER STATE permission on the server.
See Also
Dynamic Management Views and Functions (Transact-SQL )
SQL Server Operating System Related Dynamic Management Views (Transact-SQL )
sys.dm_os_tasks (Transact-SQL)
10/1/2018 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2008) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
Returns one row for each task that is active in the instance of SQL Server.
NOTE
To call this from Azure SQL Data Warehouse or Parallel Data Warehouse, use the name sys.dm_pdw_nodes_os_tasks.
DONE: Completed.
Permissions
On SQL Server, requires VIEW SERVER STATE permission.
On SQL Database, requires the VIEW DATABASE STATE permission in the database.
Examples
A. Monitoring parallel requests
For requests that are executed in parallel, you will see multiple rows for the same combination of (<session_id>,
<request_id>). Use the following query to find the Configure the max degree of parallelism Server
Configuration Option for all active requests.
NOTE
A request_id is unique within a session.
SELECT
task_address,
task_state,
context_switches_count,
pending_io_count,
pending_io_byte_count,
pending_io_byte_average,
scheduler_id,
session_id,
exec_context_id,
request_id,
worker_address,
host_address
FROM sys.dm_os_tasks
ORDER BY session_id, request_id;
See Also
SQL Server Operating System Related Dynamic Management Views (Transact-SQL )
sys.dm_os_threads (Transact-SQL)
10/1/2018 • 3 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2008) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
Returns a list of all SQL Server Operating System threads that are running under the SQL Server process.
NOTE
To call this from Azure SQL Data Warehouse or Parallel Data Warehouse, use the name sys.dm_pdw_nodes_os_threads.
Permissions
On SQL Server, requires VIEW SERVER STATE permission.
On SQL Database, requires the VIEW DATABASE STATE permission in the database.
Examples
Upon startup, SQL Server starts threads and then associates workers with those threads. However, external
components, such as an extended stored procedure, can start threads under the SQL Server process. SQL Server
has no control of these threads. sys.dm_os_threads can provide information about rogue threads that consume
resources in the SQL Server process.
The following query is used to find workers, along with time used for execution, that are running threads not
started by SQL Server.
NOTE
For conciseness, the following query uses an asterisk ( * ) in the SELECT statement. You should avoid using the asterisk (*),
especially against catalog views, dynamic management views, and system table-valued functions. Future upgrades and
releases of Microsoft SQL Server may add columns and change the order of columns to these views and functions. These
changes might break applications that expect a particular order and number of columns.
SELECT *
FROM sys.dm_os_threads
WHERE started_by_sqlservr = 0;
See Also
sys.dm_os_workers (Transact-SQL )
SQL Server Operating System Related Dynamic Management Views (Transact-SQL )
sys.dm_os_virtual_address_dump (Transact-SQL)
10/1/2018 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2008) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
Returns information about a range of pages in the virtual address space of the calling process.
NOTE
This information is also returned by the VirtualQuery Windows API.
NOTE
To call this from Azure SQL Data Warehouse or Parallel Data Warehouse, use the name
sys.dm_pdw_nodes_os_virtual_address_dump.
- PAGE_READONLY
- PAGE_READWRITE
- PAGE_NOACCESS
- PAGE_WRITECOPY
- PAGE_EXECUTE
- PAGE_EXECUTE_READ
- PAGE_EXECUTE_READWRITE
- PAGE_EXECUTE_WRITECOPY
- PAGE_GUARD
- PAGE_NOCACHE
Is not nullable.
- MEM_COMMIT
- MEM_RESERVE
- MEM_FREE
Is not nullable.
- PAGE_READONLY
- PAGE_READWRITE
- PAGE_NOACCESS
- PAGE_WRITECOPY
- PAGE_EXECUTE
- PAGE_EXECUTE_READ
- PAGE_EXECUTE_READWRITE
- PAGE_EXECUTE_WRITECOPY
- PAGE_GUARD
- PAGE_NOCACHE
Is not nullable.
- MEM_PRIVATE
- MEM_MAPPED
- MEM_IMAGE
Is not nullable.
Permissions
Requires VIEW SERVER STATE permission on the server.
See Also
Dynamic Management Views and Functions (Transact-SQL )
SQL Server Operating System Related Dynamic Management Views (Transact-SQL )
sys.dm_os_volume_stats (Transact-SQL)
10/1/2018 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2008) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
Returns information about the operating system volume (directory) on which the specified databases and files are
stored in SQL Server. Use this dynamic management function to check the attributes of the physical disk drive or
return available free space information about the directory.
Transact-SQL Syntax Conventions
Syntax
sys.dm_os_volume_stats (database_id, file_id)
Arguments
database_id
ID of the database. database_id is int, with no default. Cannot be NULL.
file_id
ID of the file. file_id is int, with no default. Cannot be NULL.
Table Returned
Security
Permissions
Requires VIEW SERVER STATE permission.
Examples
A. Return total space and available space for all database files
The following example returns the total space and available space (in bytes) for all database files in the instance of
SQL Server.
B. Return total space and available space for the current database
The following example returns the total space and available space (in bytes) for the database files in the current
database.
See Also
sys.master_files (Transact-SQL )
sys.database_files (Transact-SQL )
sys.dm_os_waiting_tasks (Transact-SQL)
10/1/2018 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2008) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
Returns information about the wait queue of tasks that are waiting on some resource.
NOTE
To call this from Azure SQL Data Warehouse or Parallel Data Warehouse, use the name
sys.dm_pdw_nodes_os_waiting_tasks.
resource_description column
The resource_description column has the following possible values.
Thread-pool resource owner:
threadpool id=scheduler<hex-address>
Parallel query resource owner:
exchangeEvent id={Port|Pipe}<hex-address> WaitType=<exchange-wait-type> nodeId=<exchange-node-
id>
Exchange-wait-type:
e_waitNone
e_waitPipeNewRow
e_waitPipeGetRow
e_waitSynchronizeConsumerOpen
e_waitPortOpen
e_waitPortClose
e_waitRange
Lock resource owner:
<type-specific-description> id=lock<lock-hex-address> mode=<mode> associatedObjectId=<associated-
obj-id>
<type-specific-description> can be:
For DATABASE: databaselock subresource=<databaselock-subresource> dbid=<db-id>
For FILE: filelock fileid=<file-id> subresource=<filelock-subresource> dbid=<db-id>
For OBJECT: objectlock lockPartition=<lock-partition-id> objid=<obj-id> subresource=
<objectlock-subresource> dbid=<db-id>
For PAGE: pagelock fileid=<file-id> pageid=<page-id> dbid=<db-id> subresource=<pagelock-
subresource>
For Key: keylock hobtid=<hobt-id> dbid=<db-id>
For EXTENT: extentlock fileid=<file-id> pageid=<page-id> dbid=<db-id>
For RID: ridlock fileid=<file-id> pageid=<page-id> dbid=<db-id>
For APPLICATION: applicationlock hash=<hash> databasePrincipalId=<role-id> dbid=<db-id>
For METADATA: metadatalock subresource=<metadata-subresource> classid=<metadatalock-
description> dbid=<db-id>
For HOBT: hobtlock hobtid=<hobt-id> subresource=<hobt-subresource> dbid=<db-id>
For ALLOCATION_UNIT: allocunitlock hobtid=<hobt-id> subresource=<alloc-unit-subresource>
dbid=<db-id>
<mode> can be:
Sch-S, Sch-M, S, U, X, IS, IU, IX, SIU, SIX, UIX, BU, RangeS -S, RangeS -U, RangeI-N, RangeI-S,
RangeI-U, RangeI-X, RangeX-, RangeX-U, RangeX-X
External resource owner:
External ExternalResource=<wait-type>
Generic resource owner:
TransactionMutex TransactionInfo Workspace=<workspace-id>
Mutex
CLRTaskJoin
CLRMonitorEvent
CLRRWLockEvent
resourceWait
Latch resource owner:
<db-id>:<file-id>:<page-in-file>
<GUID>
<latch-class> (<latch-address>)
Permissions
On SQL Server, requires VIEW SERVER STATE permission.
On SQL Database, requires the VIEW DATABASE STATE permission in the database.
Example
This example will identify blocked sessions. Execute the Transact-SQL query in SQL Server Management Studio.
See Also
SQL Server Operating System Related Dynamic Management Views (Transact-SQL )
sys.dm_os_wait_stats (Transact-SQL)
10/9/2018 • 80 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2008) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
Returns information about all the waits encountered by threads that executed. You can use this aggregated view
to diagnose performance issues with SQL Server and also with specific queries and batches.
sys.dm_exec_session_wait_stats (Transact-SQL ) provides similar information by session.
NOTE
To call this from Azure SQL Data Warehouse or Parallel Data Warehouse, use the name
sys.dm_pdw_nodes_os_wait_stats.
Permissions
On SQL Server, requires VIEW SERVER STATE permission.
On SQL Database, requires the VIEW DATABASE STATE permission in the database.
Types of Waits
Resource waits Resource waits occur when a worker requests access to a resource that is not available because
the resource is being used by some other worker or is not yet available. Examples of resource waits are locks,
latches, network and disk I/O waits. Lock and latch waits are waits on synchronization objects
Queue waits
Queue waits occur when a worker is idle, waiting for work to be assigned. Queue waits are most typically seen
with system background tasks such as the deadlock monitor and deleted record cleanup tasks. These tasks will
wait for work requests to be placed into a work queue. Queue waits may also periodically become active even if
no new packets have been put on the queue.
External waits
External waits occur when a SQL Server worker is waiting for an external event, such as an extended stored
procedure call or a linked server query, to finish. When you diagnose blocking issues, remember that external
waits do not always imply that the worker is idle, because the worker may actively be running some external
code.
sys.dm_os_wait_stats shows the time for waits that have completed. This dynamic management view does not
show current waits.
A SQL Server worker thread is not considered to be waiting if any of the following is true:
A resource becomes available.
A queue is nonempty.
An external process finishes.
Although the thread is no longer waiting, the thread does not have to start running immediately. This is
because such a thread is first put on the queue of runnable workers and must wait for a quantum to run
on the scheduler.
In SQL Server the wait-time counters are bigint values and therefore are not as prone to counter rollover
as the equivalent counters in earlier versions of SQL Server.
Specific types of wait times during query execution can indicate bottlenecks or stall points within the
query. Similarly, high wait times, or wait counts server wide can indicate bottlenecks or hot spots in
interaction query interactions within the server instance. For example, lock waits indicate data contention
by queries; page IO latch waits indicate slow IO response times; page latch update waits indicate incorrect
file layout.
The contents of this dynamic management view can be reset by running the following command:
NOTE
These statistics are not persisted across SQL Server restarts, and all data is cumulative since the last time the statistics were
reset or the server was started.
TYPE DESCRIPTION
AM_INDBUILD_ALLOCATION TBD
Applies to: SQL Server 2012 (11.x) through SQL Server
2017.
AM_SCHEMAMGR_UNSHARED_CACHE TBD
Applies to: SQL Server 2012 (11.x) through SQL Server
2017.
ASSEMBLY_FILTER_HASHTABLE TBD
Applies to: SQL Server 2016 (13.x) through SQL Server
2017.
ASYNC_OP_COMPLETION TBD
Applies to: SQL Server 2014 (12.x) through SQL Server
2017.
ASYNC_OP_CONTEXT_READ TBD
Applies to: SQL Server 2014 (12.x) through SQL Server
2017.
ASYNC_OP_CONTEXT_WRITE TBD
Applies to: SQL Server 2014 (12.x) through SQL Server
2017.
ASYNC_SOCKETDUP_IO TBD
Applies to: SQL Server 2016 (13.x) through SQL Server
2017.
BACKUP_OPERATOR Occurs when a task is waiting for a tape mount. To view the
tape status, query sys.dm_io_backup_tapes. If a mount
operation is not pending, this wait type may indicate a
hardware problem with the tape drive.
BLOB_METADATA TBD
Applies to: SQL Server 2016 (13.x) through SQL Server
2017.
BMPALLOCATION TBD
Applies to: SQL Server 2014 (12.x) through SQL Server
2017.
BMPBUILD TBD
Applies to: SQL Server 2014 (12.x) through SQL Server
2017.
BMPREPARTITION TBD
Applies to: SQL Server 2014 (12.x) through SQL Server
2017.
BMPREPLICATION TBD
Applies to: SQL Server 2014 (12.x) through SQL Server
2017.
BPSORT TBD
Applies to: SQL Server 2016 (13.x) through SQL Server
2017.
BROKER_DISPATCHER TBD
Applies to: SQL Server 2012 (11.x) through SQL Server
2017.
TYPE DESCRIPTION
BROKER_FORWARDER TBD
Applies to: SQL Server 2012 (11.x) through SQL Server
2017.
BROKER_MASTERSTART Occurs when a task is waiting for the primary event handler
of the Service Broker to start. This should occur very briefly.
BROKER_START TBD
Applies to: SQL Server 2016 (13.x) through SQL Server
2017.
BROKER_TASK_SHUTDOWN TBD
Applies to: SQL Server 2014 (12.x) through SQL Server
2017.
BROKER_TASK_STOP Occurs when the Service Broker queue task handler tries to
shut down the task. The state check is serialized and must be
in a running state beforehand.
BROKER_TASK_SUBMIT TBD
Applies to: SQL Server 2014 (12.x) through SQL Server
2017.
BROKER_TO_FLUSH Occurs when the Service Broker lazy flusher flushes the in-
memory transmission objects to a work table.
BROKER_TRANSMISSION_OBJECT TBD
Applies to: SQL Server 2012 (11.x) through SQL Server
2017.
TYPE DESCRIPTION
BROKER_TRANSMISSION_TABLE TBD
Applies to: SQL Server 2012 (11.x) through SQL Server
2017.
BROKER_TRANSMISSION_WORK TBD
Applies to: SQL Server 2012 (11.x) through SQL Server
2017.
CHANGE_TRACKING_WAITFORCHANGES TBD
Applies to: SQL Server 2012 (11.x) through SQL Server
2017.
CHECK_SCANNER_MUTEX TBD
Applies to: SQL Server 2016 (13.x) through SQL Server
2017.
CHECK_TABLES_INITIALIZATION TBD
Applies to: SQL Server 2016 (13.x) through SQL Server
2017.
CHECK_TABLES_SINGLE_SCAN TBD
Applies to: SQL Server 2016 (13.x) through SQL Server
2017.
CHECK_TABLES_THREAD_BARRIER TBD
Applies to: SQL Server 2016 (13.x) through SQL Server
2017.
CHECKPOINT_QUEUE Occurs while the checkpoint task is waiting for the next
checkpoint request.
CMEMPARTITIONED TBD
Applies to: SQL Server 2014 (12.x) through SQL Server
2017.
COLUMNSTORE_BUILD_THROTTLE TBD
Applies to: SQL Server 2014 (12.x) through SQL Server
2017.
TYPE DESCRIPTION
COLUMNSTORE_COLUMNDATASET_SESSION_LIST TBD
Applies to: SQL Server 2016 (13.x) through SQL Server
2017.
COMMIT_TABLE TBD
CONNECTION_ENDPOINT_LOCK TBD
Applies to: SQL Server 2016 (13.x) through SQL Server
2017.
COUNTRECOVERYMGR TBD
Applies to: SQL Server 2012 (11.x) through SQL Server
2017.
CREATE_DATINISERVICE TBD
Applies to: SQL Server 2012 (11.x) through SQL Server
2017.
DBCC_SCALE_OUT_EXPR_CACHE TBD
Applies to: SQL Server 2012 (11.x) through SQL Server
2017.
DBSEEDING_FLOWCONTROL TBD
Applies to: SQL Server 2014 (12.x) through SQL Server
2017.
DBSEEDING_OPERATION TBD
Applies to: SQL Server 2014 (12.x) through SQL Server
2017.
DEADLOCK_TASK_SEARCH Large waiting time on this resource indicates that the server
is executing queries on top of sys.dm_os_waiting_tasks, and
these queries are blocking deadlock monitor from running
deadlock search. This wait type is used by deadlock monitor
only. Queries on top of sys.dm_os_waiting_tasks use
DEADLOCK_ENUM_MUTEX.
DIRECTLOGCONSUMER_LIST TBD
Applies to: SQL Server 2016 (13.x) through SQL Server
2017.
DIRTY_PAGE_POLL TBD
Applies to: SQL Server 2012 (11.x) through SQL Server
2017.
DIRTY_PAGE_SYNC TBD
Applies to: SQL Server 2012 (11.x) through SQL Server
2017.
DIRTY_PAGE_TABLE_LOCK TBD
Applies to: SQL Server 2016 (13.x) through SQL Server
2017.
TYPE DESCRIPTION
DISPATCHER_PRIORITY_QUEUE_SEMAPHORE TBD
Applies to: SQL Server 2012 (11.x) through SQL Server
2017.
DISPATCHER_QUEUE_SEMAPHORE Occurs when a thread from the dispatcher pool is waiting for
more work to process. The wait time for this wait type is
expected to increase when the dispatcher is idle.
DLL_LOADING_MUTEX Occurs once while waiting for the XML parser DLL to load.
DPT_ENTRY_LOCK TBD
Applies to: SQL Server 2016 (13.x) through SQL Server
2017.
DROP_DATABASE_TIMER_TASK TBD
Applies to: SQL Server 2014 (12.x) through SQL Server
2017.
DTCNEW_ENLIST TBD
Applies to: SQL Server 2016 (13.x) through SQL Server
2017.
DTCNEW_PREPARE TBD
Applies to: SQL Server 2016 (13.x) through SQL Server
2017.
DTCNEW_RECOVERY TBD
Applies to: SQL Server 2016 (13.x) through SQL Server
2017.
DTCNEW_TM TBD
Applies to: SQL Server 2016 (13.x) through SQL Server
2017.
DTCNEW_TRANSACTION_ENLISTMENT TBD
Applies to: SQL Server 2016 (13.x) through SQL Server
2017.
DTCPNTSYNC TBD
Applies to: SQL Server 2012 (11.x) through SQL Server
2017.
DUMP_LOG_COORDINATOR_QUEUE TBD
ENABLE_EMPTY_VERSIONING TBD
Applies to: SQL Server 2012 (11.x) through SQL Server
2017.
ENABLE_VERSIONING Occurs when SQL Server waits for all update transactions in
this database to finish before declaring the database ready to
transition to snapshot isolation allowed state. This state is
used when SQL Server enables snapshot isolation by using
the ALTER DATABASE statement.
EXTERNAL_RG_UPDATE TBD
Applies to: SQL Server 2016 (13.x) through SQL Server
2017.
EXTERNAL_SCRIPT_NETWORK_IO TBD
Applies to: SQL Server 2017 (14.x) through current.
EXTERNAL_SCRIPT_PREPARE_SERVICE TBD
Applies to: SQL Server 2016 (13.x) through SQL Server
2017.
EXTERNAL_SCRIPT_SHUTDOWN TBD
Applies to: SQL Server 2016 (13.x) through SQL Server
2017.
EXTERNAL_WAIT_ON_LAUNCHER, TBD
Applies to: SQL Server 2016 (13.x) through SQL Server
2017.
FABRIC_HADR_TRANSPORT_CONNECTION TBD
Applies to: SQL Server 2014 (12.x) through SQL Server
2017.
FABRIC_REPLICA_CONTROLLER_LIST TBD
Applies to: SQL Server 2014 (12.x) through SQL Server
2017.
TYPE DESCRIPTION
FABRIC_REPLICA_CONTROLLER_STATE_AND_CONFIG TBD
Applies to: SQL Server 2014 (12.x) through SQL Server
2017.
FABRIC_REPLICA_PUBLISHER_EVENT_PUBLISH TBD
Applies to: SQL Server 2014 (12.x) through SQL Server
2017.
FABRIC_REPLICA_PUBLISHER_SUBSCRIBER_LIST TBD
Applies to: SQL Server 2014 (12.x) through SQL Server
2017.
FABRIC_WAIT_FOR_BUILD_REPLICA_EVENT_PROCESSING TBD
Applies to: SQL Server 2014 (12.x) through SQL Server
2017.
FEATURE_SWITCHES_UPDATE TBD
Applies to: SQL Server 2014 (12.x) through SQL Server
2017.
FFT_NSO_DB_KILL_FLAG TBD
Applies to: SQL Server 2012 (11.x) through SQL Server
2017.
FFT_NSO_DB_LIST TBD
Applies to: SQL Server 2012 (11.x) through SQL Server
2017.
FFT_NSO_FCB TBD
Applies to: SQL Server 2012 (11.x) through SQL Server
2017.
FFT_NSO_FCB_FIND TBD
Applies to: SQL Server 2012 (11.x) through SQL Server
2017.
FFT_NSO_FCB_PARENT TBD
Applies to: SQL Server 2012 (11.x) through SQL Server
2017.
FFT_NSO_FCB_RELEASE_CACHED_ENTRIES TBD
Applies to: SQL Server 2012 (11.x) through SQL Server
2017.
TYPE DESCRIPTION
FFT_NSO_FCB_STATE TBD
Applies to: SQL Server 2014 (12.x) through SQL Server
2017.
FFT_NSO_FILEOBJECT TBD
Applies to: SQL Server 2012 (11.x) through SQL Server
2017.
FFT_NSO_TABLE_LIST TBD
Applies to: SQL Server 2012 (11.x) through SQL Server
2017.
FFT_NTFS_STORE TBD
Applies to: SQL Server 2012 (11.x) through SQL Server
2017.
FFT_RECOVERY TBD
Applies to: SQL Server 2012 (11.x) through SQL Server
2017.
FFT_RSFX_COMM TBD
Applies to: SQL Server 2012 (11.x) through SQL Server
2017.
FFT_RSFX_WAIT_FOR_MEMORY TBD
Applies to: SQL Server 2012 (11.x) through SQL Server
2017.
FFT_STARTUP_SHUTDOWN TBD
Applies to: SQL Server 2012 (11.x) through SQL Server
2017.
FFT_STORE_DB TBD
Applies to: SQL Server 2012 (11.x) through SQL Server
2017.
FFT_STORE_ROWSET_LIST TBD
Applies to: SQL Server 2012 (11.x) through SQL Server
2017.
FFT_STORE_TABLE TBD
Applies to: SQL Server 2012 (11.x) through SQL Server
2017.
FILE_VALIDATION_THREADS TBD
Applies to: SQL Server 2016 (13.x) through SQL Server
2017.
FILESTREAM_CACHE TBD
Applies to: SQL Server 2012 (11.x) through SQL Server
2017.
FILESTREAM_CHUNKER TBD
Applies to: SQL Server 2012 (11.x) through SQL Server
2017.
TYPE DESCRIPTION
FILESTREAM_CHUNKER_INIT TBD
Applies to: SQL Server 2012 (11.x) through SQL Server
2017.
FILESTREAM_FCB TBD
Applies to: SQL Server 2012 (11.x) through SQL Server
2017.
FILESTREAM_FILE_OBJECT TBD
Applies to: SQL Server 2012 (11.x) through SQL Server
2017.
FILESTREAM_WORKITEM_QUEUE TBD
Applies to: SQL Server 2012 (11.x) through SQL Server
2017.
FILETABLE_SHUTDOWN TBD
Applies to: SQL Server 2012 (11.x) through SQL Server
2017.
FOREIGN_REDO TBD
Applies to: SQL Server 2017 (14.x) through current.
FORWARDER_TRANSITION TBD
Applies to: SQL Server 2016 (13.x) through SQL Server
2017.
FT_MASTER_MERGE_COORDINATOR TBD
Applies to: SQL Server 2012 (11.x) through SQL Server
2017.
FT_PROPERTYLIST_CACHE TBD
Applies to: SQL Server 2012 (11.x) through SQL Server
2017.
GDMA_GET_RESOURCE_OWNER TBD
Applies to: SQL Server 2012 (11.x) through SQL Server
2017.
GHOSTCLEANUP_UPDATE_STATS TBD
Applies to: SQL Server 2017 (14.x) through SQL Server
2017.
GHOSTCLEANUPSYNCMGR TBD
Applies to: SQL Server 2012 (11.x) through SQL Server
2017.
GLOBAL_QUERY_CANCEL TBD
Applies to: SQL Server 2017 (14.x) through SQL Server
2017.
TYPE DESCRIPTION
GLOBAL_QUERY_CLOSE TBD
Applies to: SQL Server 2016 (13.x) through SQL Server
2017.
GLOBAL_QUERY_CONSUMER TBD
Applies to: SQL Server 2017 (14.x) through SQL Server
2017.
GLOBAL_QUERY_PRODUCER TBD
Applies to: SQL Server 2017 (14.x) through SQL Server
2017.
GLOBAL_TRAN_CREATE TBD
Applies to: SQL Server 2016 (13.x) through SQL Server
2017.
GLOBAL_TRAN_UCS_SESSION TBD
Applies to: SQL Server 2016 (13.x) through SQL Server
2017.
HADR_AR_UNLOAD_COMPLETED TBD
Applies to: SQL Server 2012 (11.x) through SQL Server
2017.
HADR_CONNECTIVITY_INFO TBD
Applies to: SQL Server 2012 (11.x) through SQL Server
2017.
HADR_DATABASE_WAIT_FOR_RECOVERY TBD
Applies to: SQL Server 2016 (13.x) through SQL Server
2017.
HADR_DBSEEDING TBD
Applies to: SQL Server 2014 (12.x) through SQL Server
2017.
HADR_DBSEEDING_LIST TBD
Applies to: SQL Server 2014 (12.x) through SQL Server
2017.
HADR_FABRIC_CALLBACK TBD
Applies to: SQL Server 2014 (12.x) through SQL Server
2017.
HADR_FILESTREAM_PREPROC TBD
Applies to: SQL Server 2016 (13.x) through SQL Server
2017.
HADR_LOGCAPTURE_WAIT Waiting for log records to become available. Can occur either
when waiting for new log records to be generated by
connections or for I/O completion when reading log not in
the cache. This is an expected wait if the log scan is caught
up to the end of log or is reading from disk.,
Applies to: SQL Server 2012 (11.x) through SQL Server
2017.
HADR_SEEDING_CANCELLATION TBD
Applies to: SQL Server 2016 (13.x) through SQL Server
2017.
HADR_SEEDING_FILE_LIST TBD
Applies to: SQL Server 2016 (13.x) through SQL Server
2017.
HADR_SEEDING_LIMIT_BACKUPS TBD
Applies to: SQL Server 2016 (13.x) through SQL Server
2017.
HADR_SEEDING_SYNC_COMPLETION TBD
Applies to: SQL Server 2016 (13.x) through SQL Server
2017.
HADR_SEEDING_TIMEOUT_TASK TBD
Applies to: SQL Server 2016 (13.x) through SQL Server
2017.
HADR_SEEDING_WAIT_FOR_COMPLETION TBD
Applies to: SQL Server 2016 (13.x) through SQL Server
2017.
HADR_TDS_LISTENER_SYNC Either the internal Always On system or the WSFC cluster will
request that listeners are started or stopped. The processing
of this request is always asynchronous, and there is a
mechanism to remove redundant requests. There are also
moments that this process is suspended because of
configuration changes. All waits related with this listener
synchronization mechanism use this wait type. Internal use
only.,
Applies to: SQL Server 2012 (11.x) through SQL Server
2017.
HADR_THROTTLE_LOG_RATE_GOVERNOR TBD
Applies to: SQL Server 2016 (13.x) through SQL Server
2017.
HADR_THROTTLE_LOG_RATE_LOG_SIZE TBD
Applies to: SQL Server 2017 (14.x) through SQL Server
2017.
HADR_THROTTLE_LOG_RATE_SEEDING TBD
Applies to: SQL Server 2017 (14.x) through SQL Server
2017.
HADR_THROTTLE_LOG_RATE_SEND_RECV_QUEUE_SIZE TBD
Applies to: SQL Server 2017 (14.x) through SQL Server
2017.
HADR_TIMER_TASK Waiting to get the lock on the timer task object and is also
used for the actual waits between times that work is being
performed. For example, for a task that runs every 10
seconds, after one execution, Always On Availability Groups
waits about 10 seconds to reschedule the task, and the wait
is included here.,
Applies to: SQL Server 2012 (11.x) through SQL Server
2017.
HADR_XRF_STACK_ACCESS Accessing (look up, add, and delete) the extended recovery
fork stack for an Always On availability database.,
Applies to: SQL Server 2012 (11.x) through SQL Server
2017.
HCCO_CACHE TBD
Applies to: SQL Server 2016 (13.x) through SQL Server
2017.
HK_RESTORE_FILEMAP TBD
Applies to: SQL Server 2016 (13.x) through SQL Server
2017.
HKCS_PARALLEL_MIGRATION TBD
Applies to: SQL Server 2016 (13.x) through SQL Server
2017.
HKCS_PARALLEL_RECOVERY TBD
Applies to: SQL Server 2016 (13.x) through SQL Server
2017.
HTBUILD TBD
Applies to: SQL Server 2012 (11.x) through SQL Server
2017.
HTDELETE TBD
Applies to: SQL Server 2014 (12.x) through SQL Server
2017.
HTMEMO TBD
Applies to: SQL Server 2014 (12.x) through SQL Server
2017.
TYPE DESCRIPTION
HTREINIT TBD
Applies to: SQL Server 2014 (12.x) through SQL Server
2017.
HTREPARTITION TBD
Applies to: SQL Server 2012 (11.x) through SQL Server
2017.
HTTP_STORAGE_CONNECTION TBD
Applies to: SQL Server 2014 (12.x) through SQL Server
2017.
IMPPROV_IOWAIT Occurs when SQL Server waits for a bulkload I/O to finish.
INSTANCE_LOG_RATE_GOVERNOR TBD
Applies to: SQL Server 2016 (13.x) through SQL Server
2017.
IO_QUEUE_LIMIT TBD
Applies to: SQL Server 2016 (13.x) through SQL Server
2017.
KSOURCE_WAKEUP Used by the service control task while waiting for requests
from the Service Control Manager. Long waits are expected
and do not indicate a problem.
LATCH_DT Occurs when waiting for a DT (destroy) latch. This does not
include buffer latches or transaction mark latches. A listing of
LATCH_* waits is available in sys.dm_os_latch_stats. Note that
sys.dm_os_latch_stats groups LATCH_NL, LATCH_SH,
LATCH_UP, LATCH_EX, and LATCH_DT waits together.
LATCH_EX Occurs when waiting for an EX (exclusive) latch. This does not
include buffer latches or transaction mark latches. A listing of
LATCH_* waits is available in sys.dm_os_latch_stats. Note that
sys.dm_os_latch_stats groups LATCH_NL, LATCH_SH,
LATCH_UP, LATCH_EX, and LATCH_DT waits together.
LATCH_KP Occurs when waiting for a KP (keep) latch. This does not
include buffer latches or transaction mark latches. A listing of
LATCH_* waits is available in sys.dm_os_latch_stats. Note that
sys.dm_os_latch_stats groups LATCH_NL, LATCH_SH,
LATCH_UP, LATCH_EX, and LATCH_DT waits together.
LATCH_SH Occurs when waiting for an SH (share) latch. This does not
include buffer latches or transaction mark latches. A listing of
LATCH_* waits is available in sys.dm_os_latch_stats. Note that
sys.dm_os_latch_stats groups LATCH_NL, LATCH_SH,
LATCH_UP, LATCH_EX, and LATCH_DT waits together.
LATCH_UP Occurs when waiting for an UP (update) latch. This does not
include buffer latches or transaction mark latches. A listing of
LATCH_* waits is available in sys.dm_os_latch_stats. Note that
sys.dm_os_latch_stats groups LATCH_NL, LATCH_SH,
LATCH_UP, LATCH_EX, and LATCH_DT waits together.
LOG_POOL_SCAN TBD
Applies to: SQL Server 2016 (13.x) through SQL Server
2017.
LOG_RATE_GOVERNOR TBD
Applies to: SQL Server 2016 (13.x) through SQL Server
2017.
LOGBUFFER Occurs when a task is waiting for space in the log buffer to
store a log record. Consistently high values may indicate that
the log devices cannot keep up with the amount of log being
generated by the server.
LOGCAPTURE_LOGPOOLTRUNCPOINT TBD
Applies to: SQL Server 2012 (11.x) through SQL Server
2017.
LOGMGR Occurs when a task is waiting for any outstanding log I/Os to
finish before shutting down the log while closing the
database.
LOGMGR_PMM_LOG TBD
Applies to: SQL Server 2016 (13.x) through SQL Server
2017.
TYPE DESCRIPTION
LOGMGR_QUEUE Occurs while the log writer task waits for work requests.
LOGPOOL_CACHESIZE TBD
Applies to: SQL Server 2012 (11.x) through SQL Server
2017.
LOGPOOL_CONSUMER TBD
Applies to: SQL Server 2012 (11.x) through SQL Server
2017.
LOGPOOL_CONSUMERSET TBD
Applies to: SQL Server 2012 (11.x) through SQL Server
2017.
LOGPOOL_FREEPOOLS TBD
Applies to: SQL Server 2012 (11.x) through SQL Server
2017.
LOGPOOL_MGRSET TBD
Applies to: SQL Server 2012 (11.x) through SQL Server
2017.
LOGPOOL_REPLACEMENTSET TBD
Applies to: SQL Server 2012 (11.x) through SQL Server
2017.
LOGPOOLREFCOUNTEDOBJECT_REFDONE TBD
Applies to: SQL Server 2012 (11.x) through SQL Server
2017.
MD_AGENT_YIELD TBD
Applies to: SQL Server 2012 (11.x) through SQL Server
2017.
MD_LAZYCACHE_RWLOCK TBD
Applies to: SQL Server 2012 (11.x) through SQL Server
2017.
MEMORY_ALLOCATION_EXT Occurs while allocating memory from either the internal SQL
Server memory pool or the operation system.,
Applies to: SQL Server 2016 (13.x) through SQL Server
2017.
MEMORY_GRANT_UPDATE TBD
Applies to: SQL Server 2017 (14.x) through SQL Server
2017.
TYPE DESCRIPTION
METADATA_LAZYCACHE_RWLOCK TBD
Applies to: SQL Server 2008 R2 only.
MIGRATIONBUFFER TBD
Applies to: SQL Server 2017 (14.x) through SQL Server
2017.
MSSEARCH Occurs during Full-Text Search calls. This wait ends when the
full-text operation completes. It does not indicate contention,
but rather the duration of full-text operations.
NETWORKSXMLMGRLOAD TBD
Applies to: SQL Server 2016 (13.x) through SQL Server
2017.
NODE_CACHE_MUTEX TBD
OLEDB Occurs when SQL Server calls the SQL Server Native Client
OLE DB Provider. This wait type is not used for
synchronization. Instead, it indicates the duration of calls to
the OLE DB provider.
PARALLEL_REDO_DRAIN_WORKER TBD
Applies to: SQL Server 2016 (13.x) through SQL Server
2017.
PARALLEL_REDO_FLOW_CONTROL TBD
Applies to: SQL Server 2016 (13.x) through SQL Server
2017.
TYPE DESCRIPTION
PARALLEL_REDO_LOG_CACHE TBD
Applies to: SQL Server 2016 (13.x) through SQL Server
2017.
PARALLEL_REDO_TRAN_LIST TBD
Applies to: SQL Server 2016 (13.x) through SQL Server
2017.
PARALLEL_REDO_TRAN_TURN TBD
Applies to: SQL Server 2016 (13.x) through SQL Server
2017.
PARALLEL_REDO_WORKER_SYNC TBD
Applies to: SQL Server 2016 (13.x) through SQL Server
2017.
PARALLEL_REDO_WORKER_WAIT_WORK TBD
Applies to: SQL Server 2016 (13.x) through SQL Server
2017.
PERFORMANCE_COUNTERS_RWLOCK TBD
PHYSICAL_SEEDING_DMV TBD
Applies to: SQL Server 2014 (12.x) through SQL Server
2017.
POOL_LOG_RATE_GOVERNOR TBD
Applies to: SQL Server 2016 (13.x) through SQL Server
2017.
PREEMPTIVE_COM_COGETCLASSOBJECT TBD
PREEMPTIVE_COM_CREATEACCESSOR TBD
PREEMPTIVE_COM_DELETEROWS TBD
PREEMPTIVE_COM_GETCOMMANDTEXT TBD
PREEMPTIVE_COM_GETDATA TBD
PREEMPTIVE_COM_GETNEXTROWS TBD
PREEMPTIVE_COM_GETRESULT TBD
PREEMPTIVE_COM_GETROWSBYBOOKMARK TBD
PREEMPTIVE_COM_LBFLUSH TBD
PREEMPTIVE_COM_LBLOCKREGION TBD
PREEMPTIVE_COM_LBREADAT TBD
PREEMPTIVE_COM_LBSETSIZE TBD
PREEMPTIVE_COM_LBSTAT TBD
PREEMPTIVE_COM_LBUNLOCKREGION TBD
PREEMPTIVE_COM_LBWRITEAT TBD
PREEMPTIVE_COM_QUERYINTERFACE TBD
PREEMPTIVE_COM_RELEASE TBD
PREEMPTIVE_COM_RELEASEACCESSOR TBD
PREEMPTIVE_COM_RELEASEROWS TBD
PREEMPTIVE_COM_RELEASESESSION TBD
PREEMPTIVE_COM_RESTARTPOSITION TBD
PREEMPTIVE_COM_SEQSTRMREAD TBD
PREEMPTIVE_COM_SEQSTRMREADANDWRITE TBD
PREEMPTIVE_COM_SETDATAFAILURE TBD
TYPE DESCRIPTION
PREEMPTIVE_COM_SETPARAMETERINFO TBD
PREEMPTIVE_COM_SETPARAMETERPROPERTIES TBD
PREEMPTIVE_COM_STRMLOCKREGION TBD
PREEMPTIVE_COM_STRMSEEKANDREAD TBD
PREEMPTIVE_COM_STRMSEEKANDWRITE TBD
PREEMPTIVE_COM_STRMSETSIZE TBD
PREEMPTIVE_COM_STRMSTAT TBD
PREEMPTIVE_COM_STRMUNLOCKREGION TBD
PREEMPTIVE_CONSOLEWRITE TBD
PREEMPTIVE_CREATEPARAM TBD
PREEMPTIVE_DEBUG TBD
PREEMPTIVE_DFSADDLINK TBD
PREEMPTIVE_DFSLINKEXISTCHECK TBD
PREEMPTIVE_DFSLINKHEALTHCHECK TBD
PREEMPTIVE_DFSREMOVELINK TBD
PREEMPTIVE_DFSREMOVEROOT TBD
PREEMPTIVE_DFSROOTFOLDERCHECK TBD
PREEMPTIVE_DFSROOTINIT TBD
PREEMPTIVE_DFSROOTSHARECHECK TBD
PREEMPTIVE_DTC_ABORT TBD
PREEMPTIVE_DTC_ABORTREQUESTDONE TBD
PREEMPTIVE_DTC_BEGINTRANSACTION TBD
PREEMPTIVE_DTC_COMMITREQUESTDONE TBD
PREEMPTIVE_DTC_ENLIST TBD
PREEMPTIVE_DTC_PREPAREREQUESTDONE TBD
TYPE DESCRIPTION
PREEMPTIVE_FILESIZEGET TBD
PREEMPTIVE_FSAOLEDB_ABORTTRANSACTION TBD
PREEMPTIVE_FSAOLEDB_COMMITTRANSACTION TBD
PREEMPTIVE_FSAOLEDB_STARTTRANSACTION TBD
PREEMPTIVE_FSRECOVER_UNCONDITIONALUNDO TBD
PREEMPTIVE_GETRMINFO TBD
PREEMPTIVE_HTTP_EVENT_WAIT TBD
Applies to: SQL Server 2016 (13.x) through SQL Server
2017.
PREEMPTIVE_HTTP_REQUEST TBD
Applies to: SQL Server 2016 (13.x) through SQL Server
2017.
PREEMPTIVE_LOCKMONITOR TBD
PREEMPTIVE_MSS_RELEASE TBD
PREEMPTIVE_ODBCOPS TBD
PREEMPTIVE_OLE_UNINIT TBD
PREEMPTIVE_OLEDB_ABORTORCOMMITTRAN TBD
PREEMPTIVE_OLEDB_ABORTTRAN TBD
PREEMPTIVE_OLEDB_GETDATASOURCE TBD
PREEMPTIVE_OLEDB_GETLITERALINFO TBD
PREEMPTIVE_OLEDB_GETPROPERTIES TBD
PREEMPTIVE_OLEDB_GETPROPERTYINFO TBD
PREEMPTIVE_OLEDB_GETSCHEMALOCK TBD
PREEMPTIVE_OLEDB_JOINTRANSACTION TBD
PREEMPTIVE_OLEDB_RELEASE TBD
TYPE DESCRIPTION
PREEMPTIVE_OLEDB_SETPROPERTIES TBD
PREEMPTIVE_OLEDBOPS TBD
PREEMPTIVE_OS_ACCEPTSECURITYCONTEXT TBD
PREEMPTIVE_OS_ACQUIRECREDENTIALSHANDLE TBD
PREEMPTIVE_OS_AUTHENTICATIONOPS TBD
PREEMPTIVE_OS_AUTHORIZATIONOPS TBD
PREEMPTIVE_OS_AUTHZGETINFORMATIONFROMCONTEXT TBD
PREEMPTIVE_OS_AUTHZINITIALIZECONTEXTFROMSID TBD
PREEMPTIVE_OS_AUTHZINITIALIZERESOURCEMANAGER TBD
PREEMPTIVE_OS_BACKUPREAD TBD
PREEMPTIVE_OS_CLOSEHANDLE TBD
PREEMPTIVE_OS_CLUSTEROPS TBD
PREEMPTIVE_OS_COMOPS TBD
PREEMPTIVE_OS_COMPLETEAUTHTOKEN TBD
PREEMPTIVE_OS_COPYFILE TBD
PREEMPTIVE_OS_CREATEDIRECTORY TBD
PREEMPTIVE_OS_CREATEFILE TBD
PREEMPTIVE_OS_CRYPTACQUIRECONTEXT TBD
PREEMPTIVE_OS_CRYPTIMPORTKEY TBD
PREEMPTIVE_OS_CRYPTOPS TBD
PREEMPTIVE_OS_DECRYPTMESSAGE TBD
PREEMPTIVE_OS_DELETEFILE TBD
PREEMPTIVE_OS_DELETESECURITYCONTEXT TBD
PREEMPTIVE_OS_DEVICEIOCONTROL TBD
PREEMPTIVE_OS_DEVICEOPS TBD
TYPE DESCRIPTION
PREEMPTIVE_OS_DIRSVC_NETWORKOPS TBD
PREEMPTIVE_OS_DISCONNECTNAMEDPIPE TBD
PREEMPTIVE_OS_DOMAINSERVICESOPS TBD
PREEMPTIVE_OS_DSGETDCNAME TBD
PREEMPTIVE_OS_DTCOPS TBD
PREEMPTIVE_OS_ENCRYPTMESSAGE TBD
PREEMPTIVE_OS_FILEOPS TBD
PREEMPTIVE_OS_FINDFILE TBD
PREEMPTIVE_OS_FLUSHFILEBUFFERS TBD
PREEMPTIVE_OS_FORMATMESSAGE TBD
PREEMPTIVE_OS_FREECREDENTIALSHANDLE TBD
PREEMPTIVE_OS_FREELIBRARY TBD
PREEMPTIVE_OS_GENERICOPS TBD
PREEMPTIVE_OS_GETADDRINFO TBD
PREEMPTIVE_OS_GETCOMPRESSEDFILESIZE TBD
PREEMPTIVE_OS_GETDISKFREESPACE TBD
PREEMPTIVE_OS_GETFILEATTRIBUTES TBD
PREEMPTIVE_OS_GETFILESIZE TBD
PREEMPTIVE_OS_GETFINALFILEPATHBYHANDLE TBD
Applies to: SQL Server 2016 (13.x) through SQL Server
2017.
PREEMPTIVE_OS_GETLONGPATHNAME TBD
PREEMPTIVE_OS_GETPROCADDRESS TBD
PREEMPTIVE_OS_GETVOLUMENAMEFORVOLUMEMOUNTP TBD
OINT
PREEMPTIVE_OS_GETVOLUMEPATHNAME TBD
PREEMPTIVE_OS_INITIALIZESECURITYCONTEXT TBD
TYPE DESCRIPTION
PREEMPTIVE_OS_LIBRARYOPS TBD
PREEMPTIVE_OS_LOADLIBRARY TBD
PREEMPTIVE_OS_LOGONUSER TBD
PREEMPTIVE_OS_LOOKUPACCOUNTSID TBD
PREEMPTIVE_OS_MESSAGEQUEUEOPS TBD
PREEMPTIVE_OS_MOVEFILE TBD
PREEMPTIVE_OS_NETGROUPGETUSERS TBD
PREEMPTIVE_OS_NETLOCALGROUPGETMEMBERS TBD
PREEMPTIVE_OS_NETUSERGETGROUPS TBD
PREEMPTIVE_OS_NETUSERGETLOCALGROUPS TBD
PREEMPTIVE_OS_NETUSERMODALSGET TBD
PREEMPTIVE_OS_NETVALIDATEPASSWORDPOLICY TBD
PREEMPTIVE_OS_NETVALIDATEPASSWORDPOLICYFREE TBD
PREEMPTIVE_OS_OPENDIRECTORY TBD
PREEMPTIVE_OS_PDH_WMI_INIT TBD
Applies to: SQL Server 2012 (11.x) through SQL Server
2017.
PREEMPTIVE_OS_PIPEOPS TBD
PREEMPTIVE_OS_PROCESSOPS TBD
PREEMPTIVE_OS_QUERYCONTEXTATTRIBUTES TBD
Applies to: SQL Server 2012 (11.x) through SQL Server
2017.
PREEMPTIVE_OS_QUERYREGISTRY TBD
PREEMPTIVE_OS_QUERYSECURITYCONTEXTTOKEN TBD
PREEMPTIVE_OS_REMOVEDIRECTORY TBD
PREEMPTIVE_OS_REPORTEVENT TBD
PREEMPTIVE_OS_REVERTTOSELF TBD
PREEMPTIVE_OS_RSFXDEVICEOPS TBD
TYPE DESCRIPTION
PREEMPTIVE_OS_SECURITYOPS TBD
PREEMPTIVE_OS_SERVICEOPS TBD
PREEMPTIVE_OS_SETENDOFFILE TBD
PREEMPTIVE_OS_SETFILEPOINTER TBD
PREEMPTIVE_OS_SETFILEVALIDDATA TBD
PREEMPTIVE_OS_SETNAMEDSECURITYINFO TBD
PREEMPTIVE_OS_SQLCLROPS TBD
PREEMPTIVE_OS_SQMLAUNCH TBD
Applies to: SQL Server 2008 R2 through SQL Server 2016
(13.x).
PREEMPTIVE_OS_VERIFYSIGNATURE TBD
PREEMPTIVE_OS_VERIFYTRUST TBD
Applies to: SQL Server 2016 (13.x) through SQL Server
2017.
PREEMPTIVE_OS_VSSOPS TBD
PREEMPTIVE_OS_WAITFORSINGLEOBJECT TBD
PREEMPTIVE_OS_WINSOCKOPS TBD
PREEMPTIVE_OS_WRITEFILE TBD
PREEMPTIVE_OS_WRITEFILEGATHER TBD
PREEMPTIVE_OS_WSASETLASTERROR TBD
PREEMPTIVE_REENLIST TBD
PREEMPTIVE_RESIZELOG TBD
PREEMPTIVE_ROLLFORWARDREDO TBD
PREEMPTIVE_ROLLFORWARDUNDO TBD
PREEMPTIVE_SB_STOPENDPOINT TBD
PREEMPTIVE_SERVER_STARTUP TBD
PREEMPTIVE_SETRMINFO TBD
PREEMPTIVE_SHAREDMEM_GETDATA TBD
TYPE DESCRIPTION
PREEMPTIVE_SNIOPEN TBD
PREEMPTIVE_SOSHOST TBD
PREEMPTIVE_SP_SERVER_DIAGNOSTICS TBD
Applies to: SQL Server 2012 (11.x) through SQL Server
2017.
PREEMPTIVE_STARTRM TBD
PREEMPTIVE_STREAMFCB_CHECKPOINT TBD
PREEMPTIVE_STREAMFCB_RECOVER TBD
PREEMPTIVE_TRANSIMPORT TBD
PREEMPTIVE_UNMARSHALPROPAGATIONTOKEN TBD
PREEMPTIVE_VSS_CREATESNAPSHOT TBD
PREEMPTIVE_VSS_CREATEVOLUMESNAPSHOT TBD
PREEMPTIVE_XE_CALLBACKEXECUTE TBD
PREEMPTIVE_XE_CX_FILE_OPEN TBD
Applies to: SQL Server 2014 (12.x) through SQL Server
2017.
PREEMPTIVE_XE_CX_HTTP_CALL TBD
Applies to: SQL Server 2014 (12.x) through SQL Server
2017.
PREEMPTIVE_XE_DISPATCHER TBD
PREEMPTIVE_XE_ENGINEINIT TBD
PREEMPTIVE_XE_GETTARGETSTATE TBD
PREEMPTIVE_XE_SESSIONCOMMIT TBD
PREEMPTIVE_XE_TARGETFINALIZE TBD
PREEMPTIVE_XE_TARGETINIT TBD
TYPE DESCRIPTION
PREEMPTIVE_XE_TIMERRUN TBD
PRU_ROLLBACK_DEFERRED TBD
Applies to: SQL Server 2012 (11.x) through SQL Server
2017.
PWAIT_ALL_COMPONENTS_INITIALIZED TBD
Applies to: SQL Server 2012 (11.x) through SQL Server
2017.
PWAIT_COOP_SCAN TBD
Applies to: SQL Server 2012 (11.x) through SQL Server
2017.
PWAIT_DIRECTLOGCONSUMER_GETNEXT TBD
Applies to: SQL Server 2016 (13.x) through SQL Server
2017.
PWAIT_EVENT_SESSION_INIT_MUTEX TBD
Applies to: SQL Server 2012 (11.x) through SQL Server
2017.
PWAIT_FABRIC_REPLICA_CONTROLLER_DATA_LOSS TBD
Applies to: SQL Server 2016 (13.x) through SQL Server
2017.
PWAIT_HADR_ACTION_COMPLETED TBD
Applies to: SQL Server 2012 (11.x) through SQL Server
2017.
PWAIT_HADR_FAILOVER_COMPLETED TBD
Applies to: SQL Server 2012 (11.x) through SQL Server
2017.
TYPE DESCRIPTION
PWAIT_HADR_JOIN TBD
Applies to: SQL Server 2014 (12.x) through SQL Server
2017.
PWAIT_HADR_SERVER_READY_CONNECTIONS TBD
Applies to: SQL Server 2012 (11.x) through SQL Server
2017.
PWAIT_HADRSIM TBD
Applies to: SQL Server 2016 (13.x) through SQL Server
2017.
PWAIT_LOG_CONSOLIDATION_IO TBD
Applies to: SQL Server 2014 (12.x) through SQL Server
2017.
PWAIT_LOG_CONSOLIDATION_POLL TBD
Applies to: SQL Server 2014 (12.x) through SQL Server
2017.
PWAIT_PREEMPTIVE_APP_USAGE_TIMER TBD
Applies to: SQL Server 2017 (14.x) through SQL Server
2017.
PWAIT_PREEMPTIVE_AUDIT_ACCESS_WINDOWSLOG TBD
Applies to: SQL Server 2012 (11.x) through SQL Server
2017.
PWAIT_QRY_BPMEMORY TBD
Applies to: SQL Server 2012 (11.x) through SQL Server
2017.
PWAIT_REPLICA_ONLINE_INIT_MUTEX TBD
Applies to: SQL Server 2012 (11.x) through SQL Server
2017.
PWAIT_RESOURCE_SEMAPHORE_FT_PARALLEL_QUERY_SYN TBD
C Applies to: SQL Server 2012 (11.x) through SQL Server
2017.
PWAIT_SBS_FILE_OPERATION TBD
Applies to: SQL Server 2017 (14.x) through SQL Server
2017.
PWAIT_XTP_FSSTORAGE_MAINTENANCE TBD
Applies to: SQL Server 2014 (12.x) through SQL Server
2017.
PWAIT_XTP_HOST_STORAGE_WAIT TBD
Applies to: SQL Server 2014 (12.x) through SQL Server
2017.
QDS_ASYNC_CHECK_CONSISTENCY_TASK TBD
Applies to: SQL Server 2014 (12.x) through SQL Server
2017.
QDS_ASYNC_PERSIST_TASK TBD
Applies to: SQL Server 2014 (12.x) through SQL Server
2017.
QDS_ASYNC_PERSIST_TASK_START TBD
Applies to: SQL Server 2014 (12.x) through SQL Server
2017.
TYPE DESCRIPTION
QDS_ASYNC_QUEUE TBD
Applies to: SQL Server 2016 (13.x) through SQL Server
2017.
QDS_BCKG_TASK TBD
Applies to: SQL Server 2014 (12.x) through SQL Server
2017.
QDS_BLOOM_FILTER TBD
Applies to: SQL Server 2016 (13.x) through SQL Server
2017.
QDS_CLEANUP_STALE_QUERIES_TASK_MAIN_LOOP_SLEEP TBD
Applies to: SQL Server 2014 (12.x) through SQL Server
2017.
QDS_CTXS TBD
Applies to: SQL Server 2014 (12.x) through SQL Server
2017.
QDS_DB_DISK TBD
Applies to: SQL Server 2014 (12.x) through SQL Server
2017.
QDS_DYN_VECTOR TBD
Applies to: SQL Server 2014 (12.x) through SQL Server
2017.
QDS_EXCLUSIVE_ACCESS TBD
Applies to: SQL Server 2016 (13.x) through SQL Server
2017.
QDS_HOST_INIT TBD
Applies to: SQL Server 2017 (14.x) through SQL Server
2017.
QDS_LOADDB TBD
Applies to: SQL Server 2014 (12.x) through SQL Server
2017.
QDS_PERSIST_TASK_MAIN_LOOP_SLEEP TBD
Applies to: SQL Server 2014 (12.x) through SQL Server
2017.
QDS_QDS_CAPTURE_INIT TBD
Applies to: SQL Server 2016 (13.x) through SQL Server
2017.
QDS_SHUTDOWN_QUEUE TBD
Applies to: SQL Server 2014 (12.x) through SQL Server
2017.
QDS_STMT TBD
Applies to: SQL Server 2014 (12.x) through SQL Server
2017.
TYPE DESCRIPTION
QDS_STMT_DISK TBD
Applies to: SQL Server 2014 (12.x) through SQL Server
2017.
QDS_TASK_SHUTDOWN TBD
Applies to: SQL Server 2014 (12.x) through SQL Server
2017.
QDS_TASK_START TBD
Applies to: SQL Server 2014 (12.x) through SQL Server
2017.
QE_WARN_LIST_SYNC TBD
Applies to: SQL Server 2014 (12.x) through SQL Server
2017.
QRY_PARALLEL_THREAD_MUTEX TBD
Applies to: SQL Server 2012 (11.x) through SQL Server
2017.
QRY_PROFILE_LIST_MUTEX TBD
Applies to: SQL Server 2016 (13.x) through SQL Server
2017.
QUERY_EXECUTION_INDEX_SORT_EVENT_OPEN Occurs in certain cases when offline create index build is run
in parallel, and the different worker threads that are sorting
synchronize access to the sort files.
QUERY_TASK_ENQUEUE_MUTEX TBD
Applies to: SQL Server 2012 (11.x) through SQL Server
2017.
RBIO_WAIT_VLF TBD
Applies to: SQL Server 2017 (14.x) through SQL Server
2017.
RECOVERY_MGR_LOCK TBD
Applies to: SQL Server 2016 (13.x) through SQL Server
2017.
REDO_THREAD_PENDING_WORK TBD
Applies to: SQL Server 2012 (11.x) through SQL Server
2017.
REDO_THREAD_SYNC TBD
Applies to: SQL Server 2012 (11.x) through SQL Server
2017.
REMOTE_BLOCK_IO TBD
Applies to: SQL Server 2017 (14.x) through SQL Server
2017.
REMOTE_DATA_ARCHIVE_MIGRATION_DMV TBD
Applies to: SQL Server 2016 (13.x) through SQL Server
2017.
REMOTE_DATA_ARCHIVE_SCHEMA_DMV TBD
Applies to: SQL Server 2016 (13.x) through SQL Server
2017.
REMOTE_DATA_ARCHIVE_SCHEMA_TASK_QUEUE TBD
Applies to: SQL Server 2016 (13.x) through SQL Server
2017.
TYPE DESCRIPTION
REPL_HISTORYCACHE_ACCESS TBD
REPL_TRANFSINFO_ACCESS TBD
Applies to: SQL Server 2012 (11.x) through SQL Server
2017.
REPL_TRANHASHTABLE_ACCESS TBD
REPL_TRANTEXTINFO_ACCESS TBD
Applies to: SQL Server 2012 (11.x) through SQL Server
2017.
REQUEST_FOR_DEADLOCK_SEARCH Occurs while the deadlock monitor waits to start the next
deadlock search. This wait is expected between deadlock
detections, and lengthy total waiting time on this resource
does not indicate a problem.
RESERVED_MEMORY_ALLOCATION_EXT TBD
Applies to: SQL Server 2016 (13.x) through SQL Server
2017.
RESOURCE_GOVERNOR_IDLE TBD
Applies to: SQL Server 2012 (11.x) through SQL Server
2017.
RESOURCE_SEMAPHORE_MUTEX Occurs while a query waits for its request for a thread
reservation to be fulfilled. It also occurs when synchronizing
query compile and memory grant requests.
RESTORE_FILEHANDLECACHE_ENTRYLOCK TBD
Applies to: SQL Server 2016 (13.x) through SQL Server
2017.
RESTORE_FILEHANDLECACHE_LOCK TBD
Applies to: SQL Server 2016 (13.x) through SQL Server
2017.
RG_RECONFIG TBD
ROWGROUP_OP_STATS TBD
Applies to: SQL Server 2016 (13.x) through SQL Server
2017.
ROWGROUP_VERSION TBD
Applies to: SQL Server 2016 (13.x) through SQL Server
2017.
RTDATA_LIST TBD
Applies to: SQL Server 2014 (12.x) through SQL Server
2017.
SATELLITE_CARGO TBD
Applies to: SQL Server 2016 (13.x) through SQL Server
2017.
SATELLITE_SERVICE_SETUP TBD
Applies to: SQL Server 2016 (13.x) through SQL Server
2017.
TYPE DESCRIPTION
SATELLITE_TASK TBD
Applies to: SQL Server 2016 (13.x) through SQL Server
2017.
SBS_DISPATCH TBD
Applies to: SQL Server 2017 (14.x) through SQL Server
2017.
SBS_RECEIVE_TRANSPORT TBD
Applies to: SQL Server 2017 (14.x) through SQL Server
2017.
SBS_TRANSPORT TBD
Applies to: SQL Server 2017 (14.x) through SQL Server
2017.
SCAN_CHAR_HASH_ARRAY_INITIALIZATION TBD
Applies to: SQL Server 2012 (11.x) through SQL Server
2017.
SECURITY_CNG_PROVIDER_MUTEX TBD
Applies to: SQL Server 2017 (14.x) through SQL Server
2017.
SECURITY_CRYPTO_CONTEXT_MUTEX TBD
Applies to: SQL Server 2012 (11.x) through SQL Server
2017.
SECURITY_DBE_STATE_MUTEX TBD
Applies to: SQL Server 2016 (13.x) through SQL Server
2017.
SECURITY_KEYRING_RWLOCK TBD
Applies to: SQL Server 2012 (11.x) through SQL Server
2017.
SECURITY_MUTEX Occurs when there is a wait for mutexes that control access
to the global list of Extensible Key Management (EKM)
cryptographic providers and the session-scoped list of EKM
sessions.
SECURITY_RULETABLE_MUTEX TBD
Applies to: SQL Server 2012 (11.x) through SQL Server
2017.
SEMPLAT_DSI_BUILD TBD
Applies to: SQL Server 2012 (11.x) through SQL Server
2017.
SEQUENCE_GENERATION TBD
Applies to: SQL Server 2012 (11.x) through SQL Server
2017.
TYPE DESCRIPTION
SERVER_RECONFIGURE TBD
Applies to: SQL Server 2012 (11.x) through SQL Server
2017.
SESSION_WAIT_STATS_CHILDREN TBD
Applies to: SQL Server 2016 (13.x) through SQL Server
2017.
SHARED_DELTASTORE_CREATION TBD
Applies to: SQL Server 2016 (13.x) through SQL Server
2017.
SLEEP_BUFFERPOOL_HELPLW TBD
Applies to: SQL Server 2016 (13.x) through SQL Server
2017.
SLEEP_MASTERDBREADY TBD
Applies to: SQL Server 2012 (11.x) through SQL Server
2017.
SLEEP_MASTERMDREADY TBD
Applies to: SQL Server 2012 (11.x) through SQL Server
2017.
SLEEP_MASTERUPGRADED TBD
Applies to: SQL Server 2012 (11.x) through SQL Server
2017.
SLEEP_MEMORYPOOL_ALLOCATEPAGES TBD
Applies to: SQL Server 2016 (13.x) through SQL Server
2017.
SLEEP_MSDBSTARTUP Occurs when SQL Trace waits for the msdb database to
complete startup.
TYPE DESCRIPTION
SLEEP_RETRY_VIRTUALALLOC TBD
Applies to: SQL Server 2016 (13.x) through SQL Server
2017.
SLEEP_TASK Occurs when a task sleeps while waiting for a generic event
to occur.
SLEEP_WORKSPACE_ALLOCATEPAGE TBD
Applies to: SQL Server 2016 (13.x) through SQL Server
2017.
SLO_UPDATE TBD
Applies to: SQL Server 2014 (12.x) through SQL Server
2017.
SMSYNC TBD
Applies to: SQL Server 2016 (13.x) through SQL Server
2017.
SNI_CONN_DUP TBD
Applies to: SQL Server 2014 (12.x) through SQL Server
2017.
SNI_TASK_COMPLETION Occurs when there is a wait for all tasks to finish during a
NUMA node state change.
SNI_WRITE_ASYNC TBD
Applies to: SQL Server 2017 (14.x) through SQL Server
2017.
SOCKETDUPLICATEQUEUE_CLEANUP TBD
Applies to: SQL Server 2016 (13.x) through SQL Server
2017.
TYPE DESCRIPTION
SOS_MEMORY_TOPLEVELBLOCKALLOCATOR TBD
Applies to: SQL Server 2012 (11.x) through SQL Server
2017.
SOS_PHYS_PAGE_CACHE Accounts for the time a thread waits to acquire the mutex it
must acquire before it allocates physical pages or before it
returns those pages to the operating system. Waits on this
type only appear if the instance of SQL Server uses AWE
memory.,
Applies to: SQL Server 2012 (11.x) through SQL Server
2017.
SOS_SCHEDULER_YIELD Occurs when a task voluntarily yields the scheduler for other
tasks to execute. During this wait the task is waiting for its
quantum to be renewed.
SOSHOST_SLEEP Occurs when a hosted task sleeps while waiting for a generic
event to occur. Hosted tasks are used by hosted components
such as CLR.
SP_PREEMPTIVE_SERVER_DIAGNOSTICS_SLEEP TBD
Applies to: SQL Server 2012 (11.x) through SQL Server
2017.
SP_SERVER_DIAGNOSTICS_BUFFER_ACCESS TBD
Applies to: SQL Server 2012 (11.x) through SQL Server
2017.
SP_SERVER_DIAGNOSTICS_INIT_MUTEX TBD
Applies to: SQL Server 2012 (11.x) through SQL Server
2017.
SP_SERVER_DIAGNOSTICS_SLEEP TBD
Applies to: SQL Server 2012 (11.x) through SQL Server
2017.
SQLCLR_ASSEMBLY Occurs while waiting for access to the loaded assembly list in
the appdomain.
SQLTRACE_FILE_READ_IO_COMPLETION TBD
Applies to: SQL Server 2012 (11.x) through SQL Server
2017.
SQLTRACE_FILE_WRITE_IO_COMPLETION TBD
Applies to: SQL Server 2012 (11.x) through SQL Server
2017.
SQLTRACE_INCREMENTAL_FLUSH_SLEEP TBD
Applies to: SQL Server 2012 (11.x) through SQL Server
2017.
SQLTRACE_LOCK TBD
APPLIES TO: SQL Server 2008 R2 only.
SQLTRACE_PENDING_BUFFER_WRITERS TBD
Applies to: SQL Server 2012 (11.x) through SQL Server
2017.
SQLTRACE_WAIT_ENTRIES Occurs while a SQL Trace event queue waits for packets to
arrive on the queue.
STARTUP_DEPENDENCY_MANAGER TBD
Applies to: SQL Server 2012 (11.x) through SQL Server
2017.
TDS_BANDWIDTH_STATE TBD
Applies to: SQL Server 2016 (13.x) through SQL Server
2017.
TDS_INIT TBD
Applies to: SQL Server 2016 (13.x) through SQL Server
2017.
TDS_PROXY_CONTAINER TBD
Applies to: SQL Server 2016 (13.x) through SQL Server
2017.
TYPE DESCRIPTION
TEMPORAL_BACKGROUND_PROCEED_CLEANUP TBD
Applies to: SQL Server 2017 (14.x) through SQL Server
2017.
TERMINATE_LISTENER TBD
Applies to: SQL Server 2012 (11.x) through SQL Server
2017.
THREADPOOL Occurs when a task is waiting for a worker to run on. This
can indicate that the maximum worker setting is too low, or
that batch executions are taking unusually long, thus
reducing the number of workers available to satisfy other
batches.
TRACE_EVTNOTIF TBD
TRACEWRITE Occurs when the SQL Trace rowset trace provider waits for
either a free buffer or a buffer with events to process.
UCS_ENDPOINT_CHANGE TBD
Applies to: SQL Server 2012 (11.x) through SQL Server
2017.
TYPE DESCRIPTION
UCS_MANAGER TBD
Applies to: SQL Server 2012 (11.x) through SQL Server
2017.
UCS_MEMORY_NOTIFICATION TBD
Applies to: SQL Server 2012 (11.x) through SQL Server
2017.
UCS_SESSION_REGISTRATION TBD
Applies to: SQL Server 2012 (11.x) through SQL Server
2017.
UCS_TRANSPORT TBD
Applies to: SQL Server 2012 (11.x) through SQL Server
2017.
UCS_TRANSPORT_STREAM_CHANGE TBD
Applies to: SQL Server 2012 (11.x) through SQL Server
2017.
VDI_CLIENT_COMPLETECOMMAND TBD
Applies to: SQL Server 2014 (12.x) through SQL Server
2017.
VDI_CLIENT_GETCOMMAND TBD
Applies to: SQL Server 2014 (12.x) through SQL Server
2017.
VDI_CLIENT_OPERATION TBD
Applies to: SQL Server 2014 (12.x) through SQL Server
2017.
VDI_CLIENT_OTHER TBD
Applies to: SQL Server 2014 (12.x) through SQL Server
2017.
VERSIONING_COMMITTING TBD
Applies to: SQL Server 2012 (11.x) through SQL Server
2017.
WAIT_SCRIPTDEPLOYMENT_REQUEST TBD
Applies to: SQL Server 2014 (12.x) through SQL Server
2017.
TYPE DESCRIPTION
WAIT_SCRIPTDEPLOYMENT_WORKER TBD
Applies to: SQL Server 2014 (12.x) through SQL Server
2017.
WAIT_XLOGREAD_SIGNAL TBD
Applies to: SQL Server 2017 (14.x) through SQL Server
2017.
WAIT_XTP_ASYNC_TX_COMPLETION TBD
Applies to: SQL Server 2014 (12.x) through SQL Server
2017.
WAIT_XTP_CKPT_AGENT_WAKEUP TBD
Applies to: SQL Server 2014 (12.x) through SQL Server
2017.
WAIT_XTP_COMPILE_WAIT TBD
APPLIES TO: SQL Server 2017 (14.x) through SQL Server
2017.
WAIT_XTP_HOST_WAIT Occurs when waits are triggered by the database engine and
implemented by the host.,
Applies to: SQL Server 2014 (12.x) through SQL Server
2017.
WAIT_XTP_OFFLINE_CKPT_BEFORE_REDO TBD
Applies to: SQL Server 2014 (12.x) through SQL Server
2017.
WAIT_XTP_OFFLINE_CKPT_NEW_LOG Occurs when offline checkpoint is waiting for new log records
to scan.,
Applies to: SQL Server 2014 (12.x) through SQL Server
2017.
TYPE DESCRIPTION
WAIT_XTP_SERIAL_RECOVERY TBD
Applies to: SQL Server 2017 (14.x) through SQL Server
2017.
WAIT_XTP_SWITCH_TO_INACTIVE TBD
Applies to: SQL Server 2016 (13.x) through SQL Server
2017.
WAITFOR_PER_QUEUE TBD
Applies to: SQL Server 2012 (11.x) through SQL Server
2017.
WINDOW_AGGREGATES_MULTIPASS TBD
Applies to: SQL Server 2016 (13.x) through SQL Server
2017.
WINFAB_API_CALL TBD
Applies to: SQL Server 2014 (12.x) through SQL Server
2017.
WINFAB_REPLICA_BUILD_OPERATION TBD
Applies to: SQL Server 2014 (12.x) through SQL Server
2017.
TYPE DESCRIPTION
WINFAB_REPORT_FAULT TBD
Applies to: SQL Server 2016 (13.x) through SQL Server
2017.
XDB_CONN_DUP_HASH TBD
Applies to: SQL Server 2016 (13.x) through SQL Server
2017.
XDES_HISTORY TBD
Applies to: SQL Server 2012 (11.x) through SQL Server
2017.
XDES_OUT_OF_ORDER_LIST TBD
Applies to: SQL Server 2012 (11.x) through SQL Server
2017.
XDES_SNAPSHOT TBD
Applies to: SQL Server 2012 (11.x) through SQL Server
2017.
XDESTSVERMGR TBD
Applies to: SQL Server 2012 (11.x) through SQL Server
2017.
XE_CALLBACK_LIST TBD
Applies to: SQL Server 2012 (11.x) through SQL Server
2017.
TYPE DESCRIPTION
XE_CX_FILE_READ TBD
Applies to: SQL Server 2014 (12.x) through SQL Server
2017.
XE_FILE_TARGET_TVF TBD
Applies to: SQL Server 2016 (13.x) through SQL Server
2017.
XE_LIVE_TARGET_TVF TBD
Applies to: SQL Server 2012 (11.x) through SQL Server
2017.
XE_SERVICES_EVENTMANUAL TBD
XE_SERVICES_MUTEX TBD
XE_SERVICES_RWLOCK TBD
XE_SESSION_CREATE_SYNC TBD
XE_SESSION_FLUSH TBD
XE_SESSION_SYNC TBD
XE_STM_CREATE TBD
XE_TIMER_EVENT TBD
XE_TIMER_MUTEX TBD
TYPE DESCRIPTION
XE_TIMER_TASK_DONE TBD
XIO_CREDENTIAL_MGR_RWLOCK TBD
Applies to: SQL Server 2016 (13.x) through SQL Server
2017.
XIO_CREDENTIAL_RWLOCK TBD
Applies to: SQL Server 2016 (13.x) through SQL Server
2017.
XIO_EDS_MGR_RWLOCK TBD
Applies to: SQL Server 2017 (14.x) through SQL Server
2017.
XIO_EDS_RWLOCK TBD
Applies to: SQL Server 2017 (14.x) through SQL Server
2017.
XIO_IOSTATS_BLOBLIST_RWLOCK TBD
Applies to: SQL Server 2017 (14.x) through SQL Server
2017.
XIO_IOSTATS_FCBLIST_RWLOCK TBD
Applies to: SQL Server 2017 (14.x) through SQL Server
2017.
XIO_LEASE_RENEW_MGR_RWLOCK TBD
Applies to: SQL Server 2016 (13.x) through SQL Server
2017.
XTP_HOST_DB_COLLECTION TBD
Applies to: SQL Server 2014 (12.x) through SQL Server
2017.
XTP_HOST_LOG_ACTIVITY TBD
Applies to: SQL Server 2014 (12.x) through SQL Server
2017.
XTP_HOST_PARALLEL_RECOVERY TBD
Applies to: SQL Server 2016 (13.x) through SQL Server
2017.
XTP_PREEMPTIVE_TASK TBD
Applies to: SQL Server 2016 (13.x) through SQL Server
2017.
XTP_TRUNCATION_LSN TBD
Applies to: SQL Server 2016 (13.x) through SQL Server
2017.
The following XEvents are related to partition SWITCH and online index rebuild. For information about syntax,
see ALTER TABLE (Transact-SQL ) and ALTER INDEX (Transact-SQL ).
lock_request_priority_state
process_killed_by_abort_blockers
ddl_with_wait_at_low_priority
For a lock compatibility matrix, see sys.dm_tran_locks (Transact-SQL ).
See also
SQL Server Operating System Related Dynamic Management Views (Transact-SQL )
sys.dm_exec_session_wait_stats (Transact-SQL )
sys.dm_db_wait_stats (Azure SQL Database)
sys.dm_os_windows_info (Transact-SQL)
11/14/2018 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2008) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
Returns one row that displays Windows operating system version information.
Only applies to SQL Server running on Windows. To see similar informaton for SQL Server running on a non-
Windows host, such as Linux, use sys.dm_os_host_info (Transact-SQL ).
Permissions
The SELECT permission on sys.dm_os_windows_info is granted to the public role by default. If revoked, requires
VIEW SERVER STATE permission on the server.
Examples
The following example returns all columns from the sys.dm_os_windows_info view.
See Also
sys.dm_os_sys_info (Transact-SQL )
sys.dm_os_host_info
sys.dm_os_workers (Transact-SQL)
10/1/2018 • 5 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2008) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
Returns a row for every worker in the system.
NOTE
To call this from Azure SQL Data Warehouse or Parallel Data Warehouse, use the name sys.dm_pdw_nodes_os_workers.
0 =SUCCESS
3 = DEADLOCK
4 = PREMATURE_WAKEUP
258 = TIMEOUT
Remarks
If the worker state is RUNNING and the worker is running nonpreemptively, the worker address matches the
active_worker_address in sys.dm_os_schedulers.
When a worker that is waiting on an event is signaled, the worker is placed at the head of the runnable queue.
SQL Server allows for this to happen one thousand times in a row, after which the worker is placed at the end of
the queue. Moving a worker to the end of the queue has some performance implications.
Permissions
On SQL Server, requires VIEW SERVER STATE permission.
On SQL Database, requires the VIEW DATABASE STATE permission in the database.
Examples
You can use the following query to find out how long a worker has been running in a SUSPENDED or
RUNNABLE state.
SELECT
t1.session_id,
CONVERT(varchar(10), t1.status) AS status,
CONVERT(varchar(15), t1.command) AS command,
CONVERT(varchar(10), t2.state) AS worker_state,
w_suspended =
CASE t2.wait_started_ms_ticks
WHEN 0 THEN 0
ELSE
t3.ms_ticks - t2.wait_started_ms_ticks
END,
w_runnable =
CASE t2.wait_resumed_ms_ticks
WHEN 0 THEN 0
ELSE
t3.ms_ticks - t2.wait_resumed_ms_ticks
END
FROM sys.dm_exec_requests AS t1
INNER JOIN sys.dm_os_workers AS t2
ON t2.task_address = t1.task_address
CROSS JOIN sys.dm_os_sys_info AS t3
WHERE t1.scheduler_id IS NOT NULL;
In the output, when w_runnable and w_suspended are equal, this represents the time that the worker is in the
SUSPENDED state. Otherwise, w_runnable represents the time that is spent by the worker in the RUNNABLE
state. In the output, session 52 is SUSPENDED for 35,094 milliseconds.
See Also
SQL Server Operating System Related Dynamic Management Views (Transact-SQL )
Stretch Database - sys.dm_db_rda_migration_status
10/1/2018 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2016) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
Contains one row for each batch of migrated data from each Stretch-enabled table on the local instance of SQL
Server. Batches are identified by their start time and end time.
sys.dm_db_rda_migration_status is scoped to the current database context. Make sure you're in the database
context of the Stretch-enable tables for which you want to see migration status.
In SQL Server 2016 (13.x), the output of sys.dm_db_rda_migration_status is limited to 200 rows.
See Also
Stretch Database
Stretch Database -
sys.dm_db_rda_schema_update_status
10/1/2018 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2016) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
Contains one row for each schema update task for the remote data archive of each Stretch-enabled table in the
current database. Tasks are identified by their task ids.
dm_db_rda_schema_update_status is scoped to the current database context. Make sure you are in the database
context of the Stretch-enabled table for which you want to see schema update status.
See Also
Stretch Database
Transaction Related Dynamic Management Views
and Functions (Transact-SQL)
10/1/2018 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2012) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
This section contains the following dynamic management objects.
sys.dm_tran_version_store_space_usage
sys.dm_tran_active_snapshot_database_transactions
(Transact-SQL)
10/1/2018 • 4 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2008) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
In a SQL Server instance, this dynamic management view returns a virtual table for all active transactions that
generate or potentially access row versions. Transactions are included for one or more of the following conditions:
When either or both ALLOW_SNAPSHOT_ISOLATION and READ_COMMITTED_SNAPSHOT database
options are set to ON:
There is one row for each transaction that is running under snapshot isolation level, or read-
committed isolation level that is using row versioning.
There is one row for each transaction that causes a row version to be created in the current database.
For example, the transaction generates a row version by updating or deleting a row in the current
database.
When a trigger is fired, there is one row for the transaction under which the trigger is executing.
When an online indexing procedure is running, there is one row for the transaction that is creating the
index.
When Multiple Active Results Sets (MARS ) session is enabled, there is one row for each transaction that is
accessing row versions.
This dynamic management view does not include system transactions.
NOTE
To call this from Azure SQL Data Warehouse or Parallel Data Warehouse, use the name
sys.dm_pdw_nodes_tran_active_snapshot_database_transactions.
Syntax
sys.dm_tran_active_snapshot_database_transactions
Table Returned
COLUMN NAME DATA TYPE DESCRIPTION
Permissions
On SQL Server, requires VIEW SERVER STATE permission.
On SQL Database, requires the VIEW DATABASE STATE permission in the database.
Remarks
sys.dm_tran_active_snapshot_database_transactions reports transactions that are assigned a transaction
sequence number (XSN ). The XSN is assigned when the transaction first accesses the version store. In a database
that is enabled for snapshot isolation or read committed isolation using row versioning, the examples show when
an XSN is assigned to a transaction:
If a transaction is running under serializable isolation level, an XSN is assigned when the transaction first
executes a statement, such as an UPDATE operation, that causes a row version to be created.
If a transaction is running under snapshot isolation, an XSN is assigned when any data manipulation
language (DML ) statement, including a SELECT operation, is executed.
Transaction sequence numbers are serially incremented for each transaction that is started in an instance of
the Database Engine.
Examples
The following example uses a test scenario in which four concurrent transactions, each identified by a transaction
sequence number (XSN ), are running in a database that has the ALLOW_SNAPSHOT_ISOLATION and
READ_COMMITTED_SNAPSHOT options set to ON. The following transactions are running:
XSN -57 is an update operation under serializable isolation.
XSN -58 is the same as XSN -57.
XSN -59 is a select operation under snapshot isolation
XSN -60 is same as XSN -59.
The following query is executed.
SELECT
transaction_id,
transaction_sequence_num,
commit_sequence_num,
is_snapshot session_id,
first_snapshot_sequence_num,
max_version_chain_traversed,
average_version_chain_traversed,
elapsed_time_seconds
FROM sys.dm_tran_active_snapshot_database_transactions;
max_version_chain_traversed average_version_chain_traversed
--------------------------- -------------------------------
0 0
0 0
1 1
1 1
elapsed_time_seconds
--------------------
419
397
359
333
See Also
SET TRANSACTION ISOLATION LEVEL (Transact-SQL )
Dynamic Management Views and Functions (Transact-SQL )
Transaction Related Dynamic Management Views and Functions (Transact-SQL )
sys.dm_tran_active_transactions (Transact-SQL)
11/14/2018 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2008) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
Returns information about transactions for the instance of SQL Server.
NOTE
To call this from Azure SQL Data Warehouse or Parallel Data Warehouse, use the name
sys.dm_pdw_nodes_tran_active_transactions.
1 = Read/write transaction
2 = Read-only transaction
3 = System transaction
4 = Distributed transaction
1 = ACTIVE
2 = PREPARED
3 = COMMITTED
4 = ABORTED
5 = RECOVERED
Permissions
On SQL Server, requires VIEW SERVER STATE permission.
On SQL Database, requires the VIEW DATABASE STATE permission in the database.
See Also
sys.dm_tran_session_transactions (Transact-SQL )
sys.dm_tran_database_transactions (Transact-SQL )
Dynamic Management Views and Functions (Transact-SQL )
Transaction Related Dynamic Management Views and Functions (Transact-SQL )
sys.dm_tran_current_snapshot (Transact-SQL)
10/1/2018 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2008) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
Returns a virtual table that displays all active transactions at the time when the current snapshot transaction starts.
If the current transaction is not a snapshot transaction, this function returns no rows.
sys.dm_tran_current_snapshot is similar to sys.dm_tran_transactions_snapshot, except that
sys.dm_tran_current_snapshot returns only the active transactions for the current snapshot transaction.
NOTE
To call this from Azure SQL Data Warehouse or Parallel Data Warehouse, use the name
sys.dm_pdw_nodes_tran_current_snapshot.
Syntax
sys.dm_tran_current_snapshot
Table Returned
COLUMN NAME DATA TYPE DESCRIPTION
Permissions
On SQL Server, requires VIEW SERVER STATE permission.
On SQL Database, requires the VIEW DATABASE STATE permission in the database.
Examples
The following example uses a test scenario in which four concurrent transactions, each identified by a transaction
sequence number (XSN ), are running in a database that has the ALLOW_SNAPSHOT_ISOLATION and
READ_COMMITTED_SNAPSHOT options set to ON. The following transactions are running:
XSN -57 is an update operation under serializable isolation.
XSN -58 is the same as XSN -57.
XSN -59 is a select operation under snapshot isolation.
XSN -60 is the same as XSN -59.
The following query is executed within the scope of XSN -59.
SELECT
transaction_sequence_num
FROM sys.dm_tran_current_snapshot;
transaction_sequence_num
------------------------
57
58
The results show that XSN -57 and XSN -58 were active at the time that the snapshot transaction XSN -59 started.
This same result persists, even after XSN -57 and XSN -58 commit or roll back, until the snapshot transaction
finishes.
The same query is executed within the scope of XSN -60.
Here is the result set.
transaction_sequence_num
------------------------
57
58
59
The output for XSN -60 includes the same transactions that appear for XSN -59, but also includes XSN -59, which
was active when XSN -60 started.
See Also
Dynamic Management Views and Functions (Transact-SQL )
Transaction Related Dynamic Management Views and Functions (Transact-SQL )
sys.dm_tran_current_transaction (Transact-SQL)
10/1/2018 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2008) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
Returns a single row that displays the state information of the transaction in the current session.
NOTE
To call this from Azure SQL Data Warehouse or Parallel Data Warehouse, use the name
sys.dm_pdw_nodes_tran_current_transaction.
Syntax
sys.dm_tran_current_transaction
Table Returned
COLUMN NAME DATA TYPE DESCRIPTION
Permissions
On SQL Server, requires VIEW SERVER STATE permission.
On SQL Database, requires the VIEW DATABASE STATE permission in the database.
Examples
The following example uses a test scenario in which four concurrent transactions, each identified by a transaction
sequence number (XSN ), are running in a database that has the ALLOW_SNAPSHOT_ISOLATION and
READ_COMMITTED_SNAPSHOT options set to ON. The following transactions are running:
XSN -57 is an update operation under serializable isolation.
XSN -58 is the same as XSN -57.
XSN -59 is a select operation under snapshot isolation.
XSN -60 is the same as XSN -59.
The following query is executed within the scope of each transaction.
SELECT
transaction_id
,transaction_sequence_num
,transaction_is_snapshot
,first_snapshot_sequence_num
,last_transaction_sequence_num
,first_useful_sequence_num
FROM sys.dm_tran_current_transaction;
first_snapshot_sequence_num last_transaction_sequence_num
--------------------------- -----------------------------
57 61
first_useful_sequence_num
-------------------------
57
The output shows that XSN -59 is a snapshot transaction that uses XSN -57 as the first transaction that was active
when XSN -59 started. This means that XSN -59 reads data committed by transactions that have a transaction
sequence number lower than XSN -57.
Here is the result for XSN -57.
first_snapshot_sequence_num last_transaction_sequence_num
--------------------------- -----------------------------
NULL 61
first_useful_sequence_num
-------------------------
57
See Also
Dynamic Management Views and Functions (Transact-SQL )
Transaction Related Dynamic Management Views and Functions (Transact-SQL )
sys.dm_tran_database_transactions (Transact-SQL)
10/1/2018 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2008) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
Returns information about transactions at the database level.
NOTE
To call this DMV from Azure SQL Data Warehouse or Parallel Data Warehouse, use the name
sys.dm_pdw_nodes_tran_database_transactions.
2 = Read-only transaction
3 = System transaction
COLUMN NAME DATA TYPE DESCRIPTION
See Also
sys.dm_tran_active_transactions (Transact-SQL )
sys.dm_tran_session_transactions (Transact-SQL )
Dynamic Management Views and Functions (Transact-SQL )
Transaction Related Dynamic Management Views and Functions (Transact-SQL )
sys.dm_tran_locks (Transact-SQL)
10/1/2018 • 21 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2008) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
Returns information about currently active lock manager resources in SQL Server 2017. Each row represents
a currently active request to the lock manager for a lock that has been granted or is waiting to be granted.
The columns in the result set are divided into two main groups: resource and request. The resource group
describes the resource on which the lock request is being made, and the request group describes the lock
request.
NOTE
To call this from Azure SQL Data Warehouse or Parallel Data Warehouse, use the name
sys.dm_pdw_nodes_tran_locks.
SHARED_TRANSACTION_WORKSPAC
E = The request is owned by the
shared part of the transaction
workspace.
EXCLUSIVE_TRANSACTION_WORKSP
ACE = The request is owned by the
exclusive part of the transaction
workspace.
NOTIFICATION_OBJECT = The
request is owned by an internal SQL
Server component. This component
has requested the lock manager to
notify it when another component is
waiting to take the lock. The FileTable
feature is a component that uses this
value.
Permissions
On SQL Server, requires VIEW SERVER STATE permission.
On SQL Database, requires the VIEW DATABASE STATE permission in the database.
Remarks
A granted request status indicates that a lock has been granted on a resource to the requestor. A waiting
request indicates that the request has not yet been granted. The following waiting-request types are returned
by the request_status column:
A convert request status indicates that the requestor has already been granted a request for the
resource and is currently waiting for an upgrade to the initial request to be granted.
A wait request status indicates that the requestor does not currently hold a granted request on the
resource.
Because sys.dm_tran_locks is populated from internal lock manager data structures, maintaining this
information does not add extra overhead to regular processing. Materializing the view does require
access to the lock manager internal data structures. This can have minor effects on the regular
processing in the server. These effects should be unnoticeable and should only affect heavily used
resources. Because the data in this view corresponds to live lock manager state, the data can change at
any time, and rows are added and removed as locks are acquired and released. This view has no
historical information.
Two requests operate on the same resource only if all the resource-group columns are equal.
You can control the locking of read operations by using the following tools:
SET TRANSACTION ISOLATION LEVEL to specify the level of locking for a session. For more
information, see SET TRANSACTION ISOLATION LEVEL (Transact-SQL ).
Locking table hints to specify the level of locking for an individual reference of a table in a FROM
clause. For syntax and restrictions, see Table Hints (Transact-SQL ).
A resource that is running under one session ID can have more than one granted lock. Different
entities that are running under one session can each own a lock on the same resource, and the
information is displayed in the request_owner_type and request_owner_id columns that are
returned by sys.dm_tran_locks. If multiple instances of the same request_owner_type exist, the
request_owner_id column is used to distinguish each instance. For distributed transactions, the
request_owner_type and the request_owner_guid columns will show the different entity
information.
For example, Session S1 owns a shared lock on Table1; and transaction T1, which is running under
session S1, also owns a shared lock on Table1. In this case, the resource_description column that is
returned by sys.dm_tran_locks will show two instances of the same resource. The
request_owner_type column will show one instance as a session and the other as a transaction. Also,
the resource_owner_id column will have different values.
Multiple cursors that run under one session are indistinguishable and are treated as one entity.
Distributed transactions that are not associated with a session ID value are orphaned transactions and
are assigned the session ID value of -2. For more information, see KILL (Transact-SQL ).
Resource Details
The following table lists the resources that are represented in the resource_associated_entity_id column.
PAGE Represents a single page in a data file. HoBt ID. This value corresponds to
sys.partitions.hobt_id. The HoBt ID
is not always available for PAGE
resources because the HoBt ID is
extra information that can be
provided by the caller, and not all
callers can provide this information.
RID Represents a physical row in a heap. HoBt ID. This value corresponds to
sys.partitions.hobt_id. The HoBt ID
is not always available for RID
resources because the HoBt ID is
extra information that can be
provided by the caller, and not all
callers can provide this information.
HOBT Represents a heap or a B-tree. These HoBt ID. This value corresponds to
are the basic access path structures. sys.partitions.hobt_id.
ALLOCATION_UNIT Represents a set of related pages, Allocation Unit ID. This value
such as an index partition. Each corresponds to
allocation unit covers a single Index sys.allocation_units.allocation_unit
Allocation Map (IAM) chain. _id.
The following table lists the subtypes that are associated with each resource type.
RESOURCESUBTYPE SYNCHRONIZES
The following table provides the format of the resource_description column for each resource type.
The following XEvents are related to partition SWITCH and online index rebuild. For information about
syntax, see ALTER TABLE (Transact-SQL ) and ALTER INDEX (Transact-SQL ).
lock_request_priority_state
process_killed_by_abort_blockers
ddl_with_wait_at_low_priority
The existing XEvent progress_report_online_index_operation for online index operations was
extended by adding partition_number and partition_id.
Examples
A. Using sys.dm_tran_locks with other tools
The following example works with a scenario in which an update operation is blocked by another transaction.
By using sys.dm_tran_locks and other tools, information about locking resources is provided.
USE tempdb;
GO
-- Session 1
SET TRANSACTION ISOLATION LEVEL READ COMMITTED;
BEGIN TRAN
SELECT c1
FROM t_lock
WITH(holdlock, rowlock);
-- Session 2
BEGIN TRAN
UPDATE t_lock SET c1 = 10
The following query will display lock information. The value for <dbid> should be replaced with the
database_id from sys.databases.
The following query returns object information by using resource_associated_entity_id from the previous
query. This query must be executed while you are connected to the database that contains the object.
SELECT object_name(object_id), *
FROM sys.partitions
WHERE hobt_id=<resource_associated_entity_id>
-- Session 1
ROLLBACK;
GO
-- Session 2
ROLLBACK;
GO
See Also
sys.dm_tran_database_transactions (Transact-SQL )
Dynamic Management Views and Functions (Transact-SQL )
Transaction Related Dynamic Management Views and Functions (Transact-SQL )
sys.dm_tran_session_transactions (Transact-SQL)
10/1/2018 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2008) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
Returns correlation information for associated transactions and sessions.
NOTE
To call this from Azure SQL Data Warehouse or Parallel Data Warehouse, use the name
sys.dm_pdw_nodes_tran_session_transactions.
0 = System transaction.
0 = Distributed transaction or an
enlisted bound session transaction.
Permissions
On SQL Server, requires VIEW SERVER STATE permission.
On SQL Database, requires the VIEW DATABASE STATE permission in the database.
Remarks
Through bound sessions and distributed transactions, it is possible for a transaction to be running under more
than one session. In such cases, sys.dm_tran_session_transactions will show multiple rows for the same
transaction_id, one for each session under which the transaction is running.
By executing multiple requests in autocommit mode using multiple active result sets (MARS ), it is possible to have
more than one active transaction on a single session. In such cases, sys.dm_tran_session_transactions will show
multiple rows for the same session_id, one for each transaction running under that session.
See Also
Dynamic Management Views and Functions (Transact-SQL )
Transaction Related Dynamic Management Views and Functions (Transact-SQL )
sys.dm_tran_top_version_generators (Transact-SQL)
10/1/2018 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2008) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
Returns a virtual table for the objects that are producing the most versions in the version store.
sys.dm_tran_top_version_generators returns the top 256 aggregated record lengths that are grouped by the
database_id and rowset_id. sys.dm_tran_top_version_generators retrieves data by querying the
dm_tran_version_store virtual table. sys.dm_tran_top_version_generators is an inefficient view to run because
this view queries the version store, and the version store can be very large. We recommend that you use this
function to find the largest consumers of the version store.
NOTE
To call this from Azure SQL Data Warehouse or Parallel Data Warehouse, use the name
sys.dm_pdw_nodes_tran_top_version_generators.
Syntax
sys.dm_tran_top_version_generators
Table Returned
COLUMN NAME DATA TYPE DESCRIPTION
Permissions
On SQL Server, requires VIEW SERVER STATE permission.
On SQL Database, requires the VIEW DATABASE STATE permission in the database.
Remarks
Because sys.dm_tran_top_version_generators might have to read many pages as it scans the entire version
store, running sys.dm_tran_top_version_generators can interfere with system performance.
Examples
The following example uses a test scenario in which four concurrent transactions, each identified by a transaction
sequence number (XSN ), are running in a database that has the ALLOW_SNAPSHOT_ISOLATION and
READ_COMMITTED_SNAPSHOT options set to ON. The following transactions are running:
XSN -57 is an update operation under serializable isolation.
XSN -58 is the same as XSN -57.
XSN -59 is a select operation under snapshot isolation.
XSN -60 is the same as XSN -59.
The following query is executed.
SELECT
database_id,
rowset_id,
aggregated_record_length_in_bytes
FROM sys.dm_tran_top_version_generators;
The output shows that all versions are created by database_id``9 and that the versions generate from two tables.
See Also
Dynamic Management Views and Functions (Transact-SQL )
Transaction Related Dynamic Management Views and Functions (Transact-SQL )
sys.dm_tran_transactions_snapshot (Transact-SQL)
10/1/2018 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2008) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
Returns a virtual table for the sequence_number of transactions that are active when each snapshot transaction
starts. The information that is returned by this view can you help you do the following:
Find the number of currently active snapshot transactions.
Identify data modifications that are ignored by a particular snapshot transaction. For a transaction that is
active when a snapshot transaction starts, all data modifications by that transaction, even after that
transaction commits, are ignored by the snapshot transaction.
For example, consider the following output from sys.dm_tran_transactions_snapshot:
The transaction_sequence_num column identifies the transaction sequence (XSN ) number of the current snapshot
transactions. The output shows two: 59 and 60 . The snapshot_sequence_num column identifies the transaction
sequence number of the transactions that are active when each snapshot transaction starts.
The output shows that snapshot transaction XSN -59 starts while two active transactions, XSN -57 and XSN -58, are
running. If XSN -57 or XSN -58 makes data modifications, XSN -59 ignores the changes and uses row versioning to
maintain a transactionally consistent view of the database.
Snapshot transaction XSN -60 ignores data modifications made by XSN -57 and XSN -58 and also XSN 59.
Syntax
dm_tran_transactions_snapshot
Table Returned
COLUMN NAME DATA TYPE DESCRIPTION
Permissions
On SQL Server, requires VIEW SERVER STATE permission.
On SQL Database, requires the VIEW DATABASE STATE permission in the database.
Remarks
When a snapshot transaction starts, the Database Engine records all of the transactions that are active at that time.
sys.dm_tran_transactions_snapshot reports this information for all currently active snapshot transactions.
Each transaction is identified by a transaction sequence number that is assigned when the transaction begins.
Transactions start at the time a BEGIN TRANSACTION or BEGIN WORK statement is executed. However, the
Database Engine assigns the transaction sequence number with the execution of the first Transact-SQL statement
that accesses data after the BEGIN TRANSACTION or BEGIN WORK statement. The transaction sequence
numbers are incremented by one.
See Also
Dynamic Management Views and Functions (Transact-SQL )
Transaction Related Dynamic Management Views and Functions (Transact-SQL )
sys.dm_tran_version_store (Transact-SQL)
10/1/2018 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2008) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
Returns a virtual table that displays all version records in the version store. sys.dm_tran_version_store is
inefficient to run because it queries the entire version store, and the version store can be very large.
Each versioned record is stored as binary data together with some tracking or status information. Similar to
records in database tables, version-store records are stored in 8192-byte pages. If a record exceeds 8192 bytes,
the record will be split across two different records.
Because the versioned record is stored as binary, there are no problems with different collations from different
databases. Use sys.dm_tran_version_store to find the previous versions of the rows in binary representation as
they exist in the version store.
Syntax
sys.dm_tran_version_store
Table Returned
COLUMN NAME DATA TYPE DESCRIPTION
Permissions
On SQL Server, requires VIEW SERVER STATE permission.
On SQL Database, requires the VIEW DATABASE STATE permission in the database.
Examples
The following example uses a test scenario in which four concurrent transactions, each identified by a transaction
sequence number (XSN ), are running in a database that has the ALLOW_SNAPSHOT_ISOLATION and
READ_COMMITTED_SNAPSHOT options set to ON. The following transactions are running:
XSN -57 is an update operation under serializable isolation.
XSN -58 is the same as XSN -57.
XSN -59 is a select operation under snapshot isolation.
XSN -60 is the same as XSN -59.
The following query is executed.
SELECT
transaction_sequence_num,
version_sequence_num,
database_id rowset_id,
status,
min_length_in_bytes,
record_length_first_part_in_bytes,
record_image_first_part,
record_length_second_part_in_bytes,
record_image_second_part
FROM sys.dm_tran_version_store;
record_length_first_part_in_bytes
---------------------------------
29
29
29
33
record_image_first_part
--------------------------------------------------------------------
0x50000C0073000000010000000200FCB000000001000000270000000000
0x50000C0073000000020000000200FCB000000001000100270000000000
0x50000C0073000000030000000200FCB000000001000200270000000000
0x500010000100000002000000030000000300F800000000000000002E0000000000
record_length_second_part_in_bytes record_image_second_part
---------------------------------- ------------------------
0 NULL
0 NULL
0 NULL
0 NULL
The output shows that XSN -57 has created three row versions from one table and XSN -58 has created one row
version from another table.
See Also
Dynamic Management Views and Functions (Transact-SQL )
Transaction Related Dynamic Management Views and Functions (Transact-SQL )
sys.dm_tran_version_store_space_usage (Transact-
SQL)
10/1/2018 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server (starting with 2016 SP2) Azure SQL Database Azure SQL Data Warehouse
Parallel Data Warehouse
Returns a table that displays total space in tempdb used by version store records for each database.
sys.dm_tran_version_store_space_usage is efficient and not expensive to run, as it does not navigate through
individual version store records, and returns aggregated version store space consumed in tempdb per database.
Each versioned record is stored as binary data, together with some tracking or status information. Similar to
records in database tables, version-store records are stored in 8192-byte pages. If a record exceeds 8192 bytes, the
record will be split across two different records.
Because the versioned record is stored as binary, there are no problems with different collations from different
databases. Use sys.dm_tran_version_store_space_usage to monitor and plan tempdb size based on the version
store space usage of databases in a SQL Server instance.
Permissions
On SQL Server, requires VIEW SERVER STATE permission.
Examples
The following query can be used to determine space consumed in tempdb, by version store of each database in a
SQL Server instance.
SELECT
DB_NAME(database_id) as 'Database Name',
reserved_page_count,
reserved_space_kb
FROM sys.dm_tran_version_store_space_usage;
See Also
Dynamic Management Views and Functions (Transact-SQL )
Transaction Related Dynamic Management Views and Functions (Transact-SQL )