QUEST SQL DMV Poster
QUEST SQL DMV Poster
COMMON LANGUAGE RUNTIME Returns information about queries that have acquired memory grants or that still require a memory grant to execute.
This DMV is useful for determining query timeouts, since only queries that have to wait on a memory grant will
appear in this view.
Returns information providing a complete picture of the process memory address space in kilobytes, including
things like the page_fault_count, amount of virtual address space available and committed, process physical and
virtual memory, and so forth.
Returns a row for each database master key password (used to protect the master keys kept in the credential store)
created with the system stored procedure sp_control_dbmasterkey_password stored procedure.
sys.openkeys
RESOURCE GOVERNOR
Useful for understanding and troubleshooting CLR objects executing within SQL Server. CLR objects are cached for better Sys.dm_resource_governor_configuration
performance after they are used and are not destroyed immediately. CLR objects are unloaded only when SQL Server comes sys.dm_exec_query_optimizer_info sys.dm_os_performance_counters Returns a row for each encryption key that is open in the current session. Returns a row containing the current configuration state of the Resource Governor in memory. To see the same data,
under memory pressure. Returns detailed statistics about the operation of the SQL Server query optimizer, such as the total number of Returns a row per performance counter, the same counters as in Windows PerfMon, maintained by the server. but stored in the long-term metadata, refer to sys.resource_governor_configuration.
optimizations, the elapsed time value, or sophisticated assessments like comparing the query optimization cost of To calculate a discreet value for the various per-second counters, you must sample two discrete values and then sys.securable_classes
sys.dm_clr_appdomains the current workload to that of a tuned workload. Some counters shown by this DMV are for internal use only. subtract the earlier cumulative per-second value from the later. Returns a list of all securable classes on the instance. Sys.dm_resource_governor_resource_pools
Returns a row for each AppDomain, the unit of isolation for an application running in .NET, running on the server. Returns a row for each current resource pool that is active in memory – their states, current configurations, and
SQL Server creates one AppDomain per database per owner so that all CLR objects are always executed in the same sys.dm_exec_query_plan sys.dm_os_schedulers sys.server_permissions resource pool statistics. To see the same data, but stored in the long-term metadata, refer to sys.resource_governor_
Returns a given query’s Showplan output in XML format, as specified by the plan handle. Returns one row per scheduler for schedulers mapped to an individual processor. Active_worker scheduler threads Returns a row for each server permission granted, including servers, server principals and endpoints.
AppDomain. resource_pools.
are those devoted to the regular user-controlled work of the server, such as queries and SSIS jobs, while a variety of
sys.dm_exec_query_resource_semaphores system and hidden schedulers may be active on the system at any time. This DMV is very useful for monitoring the sys.server_principals
sys.dm_clr_loaded_assemblies Sys.dm_resource_governor_workload_groups
Returns two rows, one for the regular resource semaphore and the other for the small-query resource semafor, thread scheduler and to find runaway tasks. Returns a row for each server-level principal, such as Windows and SQL Server logins, as well as logins mapped to
Returns a row for each managed user assembly, i.e. managed code DLL files, loaded into the server address space. Returns a row for each current workload group that is active in memory, including configuration information
information about the current query-resource semaphore status. When used with sys.dm_os_memory_clerks, certificates and asymmetric keys.
and workload group statistics. To see the same data, but stored in the long-term metadata, refer to sys.resource_
sys.dm_clr_properties this DMV provides a complete picture of memory status information about query executions and allows you to sys.dm_os_stacks governor_workload_groups.
sys.server_role_members
Returns a row for each property of a CLR assembly available to the system, such as the CLR version, current state of determine whether the system can access enough memory. Used internally by SQL Server track debug data, such as outstanding allocations, and to validate the logic in a
Returns a row for each member of each fixed server role on the instance.
the hosted CLR, or the CLR install directory. component that assumes that a certain call was made. In the following example, we want to see both the original resource governor classifiers and the currently active classifiers
sys.dm_exec_query_stats for all schemas on the SQL Server instance:
sys.sql_logins
sys.dm_clr_tasks Returns one row per query statement within a cached plan, detailing aggregated performance statistics for cached sys.dm_os_sys_info USE MASTER
Returns a row for each SQL login on the instance.
Returns a row for all currently running CLR tasks. query plans. Because the information is aggregated, you may sometimes get better information by rerunning Returns a miscellaneous set of useful information about the computer, such as the hyperthread ratio, the max worker GO
this DMV. count, and other resources used by and available to SQL Server. sys.system_components_surface_area_configuration SELECT OBJECT_SCHEMA_NAME(classifier_function_id) AS ‘Metadata Schema’,
Returns a row for each executable system object, like a stored procedure or user-defined function, that can be OBJECT_NAME(classifier_function_id) AS ‘Metadata UDF Name’
sys.dm_exec_requests Sys.dm_os_sys_memory enabled or disabled by a surface area configuration component. FROM SYS.RESOURCE_GOVERNOR_CONFIGURATION
Returns one row for each request executing within SQL Server, but does not contain information for code that Returns a complete picture of memory at the operating system level, including information about total and available GO
DATABASE executes outside of SQL Server, such as distributed queries or extended stored procedures.
sys.dm_exec_sessions
Returns one row per authenticated session, including both active users and internal tasks, running anywhere on
physical memory, total and available page memory, system cache, kernel space and so forth.
sys.dm_os_tasks
Returns one row for each OS task that is active in the instance of SQL Server.
sys.symmetric_keys
Returns a row for each symmetric key created using the statement CREATE SYMMETRIC KEY.
SELECT OBJECT_SCHEMA_NAME(classifier_function_id) AS In-Memory Schema’,
OBJECT_NAME(classifier_function_id) as ‘In-Memory UDF name’
FROM SYS.DM_RESOURCE_GOVERNOR_CONFIGURATION
For SQL Server 2005, these DMVs are only usable for tempdb. sys.user_token GO
SQL Server. Returns a row for each database principal (such as a Windows login, SQL Server login, or application role) that is
sys.dm_db_file_space_usage sys.dm_os_threads part of the user token.
Returns space usage information for each file in tempdb. sys.dm_exec_sql_text Returns a row for each SQLOS threads running under the SQL Server process.
Similar to fn_get_sql in SQL Server 2000, this DMV returns the text of the SQL batch that is identified by the specified
sql_handle. sys.dm_os_virtual_address_dump
INDEX
Returns the number of pages allocated and deallocated by each session, user or internal, in tempdb.
sys.dm_exec_text_query_plan
sys.dm_db_partition_stats Returns Showplan output in text format for a given TSQL batch or a statement within the batch. It’s similar sys. sys.dm_os_wait_stats
Returns one row per partition in the database, showing page and row-count information for every partition in the dm_exec_query_plan, except that it returns data as text, is not limited in size, and may be specific to an individual Returns information about waits encountered by currently executing threads. There are a limited number of reasons SQL Server 2008 introduces the concept of extended events, a general event-handling system that can correlate data from
current database, including the space used to store and manage in-row data, LOB data, and row-overflow data for all statement within a batch. why a thread might be forced to wait before it can complete execution. Refer to the SQL Server Books On-Line for sys.dm_db_index_operational_stats SQL Server, the OS, and applications using Event Tracing for Windows.
partitions in a database. more information about all possible wait states. This is an excellent DMV to use to diagnose performance issues with Returns current low-level I/O, locking, latching, and access method activity for one or all databases, and one or all
sys.dm_exec_xml_handles SQL Server and also with specific queries and batches because it records any time anything within SQL Server has to tables, indexes and partitions within each database. Sys.dm_os_dispatcher_pools
sys.dm_db_task_space_usage Returns information about one or all active handles that opened with the sp_xml_preparedocument system wait. Returns a row for each currently active session dispatcher pool, that is, those thread pools used by system
Returns page allocation and deallocation activity by task for tempdb, excluding IAM pages. stored procedure. sys.dm_db_index_physical_stats components which are performing background processing.
sys.dm_os_waiting_tasks Returns size and fragmentation information for the data pages and index pages for one or all databases, and one or
To determine the amount of space used by internal and user objects in tempdb: To see the percentage of failed background jobs for all executed queries: Returns information about the wait queue of SQLOS tasks that are waiting on some resource, such as blocking and all tables, indexes and partitions within each database. You may also specify a scanning mode to speed processing. Sys.dm_xe_map_values
SELECT SUM(internal_object_reserved_page_count) AS internal_pages, SELECT CASE ended_count WHEN 0 latch contention. You will usually get multiple rows even if specifying a specific index on a specific table in a specific database. The Returns the extended event mapping of internal number keys as human-readable text.
(SUM(internal_object_reserved_page_count)*1.0/128) AS internal_space_MB, THEN ‘No jobs ended’ DMV returns one row for indexes for each level of the B-tree in each partition. One row is returned for heaps for the
SUM(user_object_reserved_page_count) AS user_pages, ELSE CAST((failed_lock_count + failed_giveup_count + failed_other_count) / sys.dm_os_workers IN_ROW_DATA allocation unit of each partition. One row is returned for LOB data and rwo-overflow data, if they Sys.dm_xe_object_columns
(SUM(user_object_reserved_page_count)*1.0/128) AS user_space_MB CAST(ended_count AS float) * 100 AS varchar(20)) END AS percent_failed Returns a row detailing information for every worker in the system, what it is doing and what it is waiting to do. exist in each partition. Returns the extended event schema information for specified object. The object_name must exist in sys.dm_xe_
FROM sys.dm_db_file_space_usage; FROM sys.dm_exec_background_job_queue_stats; objects.
To find out the number of data pages in the buffer cache for each database, from largest to smallest consumers of the cache: sys.dm_db_index_usage_stats
To see the total space consumed by internal objects in currently running tasks in tempdb: To see the SQL text of all cached plans who have been used at least three times: SELECT count(*)AS cached_pages, Returns a count of different types of index operations (such as seeks, scans, lookups, and updates) and the last time Sys.dm_xe_objects
SELECT session_id, SELECT usecounts, cacheobjtype, objtype, text CASE database_id each operation was performed. Returns a row for each object exposed by an event package, including events, actions, targets, predicates, and types.
SUM(internal_objects_alloc_page_count) AS task_pages, FROM sys.dm_exec_cached_plans WHEN 32767 THEN ‘ResourceDb’
SUM(internal_objects_dealloc_page_count) AS task_dealloc_pages CROSS APPLY sys.dm_exec_sql_text(plan_handle) ELSE db_name(database_id) sys.dm_db_missing_index_columns Sys.dm_xe_packages
FROM sys.dm_db_task_space_usage WHERE usecounts >= 3 END AS database Returns information about columns that are missing an index, which can then be used to create indexes on those Returns a row for each package registered with the extended events engine.
GROUP BY session_id; ORDER BY usecounts DESC; FROM sys.dm_os_buffer_descriptors columns.
GROUP BY db_name(database_id) ,database_id Sys.dm_xe_session_event_actions
To find any cursors that have been open for more than 24 hours: ORDER BY cached_pages_count DESC sys.dm_db_missing_index_details Returns a row for each event session action, including the number of times the action has been fired and its total run
SELECT name, cursor_id, creation_time, c.session_id, login_name Returns detailed information about missing indexes. Used in conjunction with the other sys.xxx_missing_inde_xxx time.
FROM sys.dm_exec_cursors(0) AS c To see all of the memory consumed by hosted components: DMVs and functions.
Sys.dm_xe_session_object_columns
sys.dm_tran_active_snapshot_database_transactions inde_xxx DMVs and functions.
Returns a virtual table for each active transaction that could potentially generate access row versions. Each To find the fraction of optimized queries containing a hint: GROUP BY h.type; Returns a row for each configuration value assigned to objects that are bound to a given session.
transaction it returns has an XSN (transaction sequence number) which is given to any transaction that accesses a SELECT (SELECT CAST (occurrence AS float) sys.dm_db_missing_index_groups
version store. FROM sys.dm_exec_query_optimizer_info WHERE counter = ‘hints’) / To associate a SQL Server session ID value with a Windows thread ID that you could then track with Windows PerfMon, use a Returns information showing which specific missing indexes are contained in a specific missing index group. Used in Sys.dm_xe_session_targets
(SELECT CAST (occurrence AS float) query like this: conjunction with the other sys.xxx_missing_inde_xxx DMVs and functions. Returns information about session targets, such as the number of times the target has been executed for the session
sys.dm_tran_active_transactions FROM sys.dm_exec_query_optimizer_info WHERE counter = ‘hints’) SELECT STasks.session_id, SThreads.os_thread_id and the total time that the target has been executing.
Returns information about transactions (such as the state of the transaction, when it began, whether it is read-only AS [Fraction Containing Hints]; FROM sys.dm_os_tasks AS STasks To grab the physical index information from AdventureWorks.Person.Address as quickly as possible:
or not, and so forth) executing within the SQL Server instance. INNER JOIN sys.dm_os_threads AS SThreads SELECT * Sys.dm_xe_sessions
To see the top 5 SQL statements executing on the server by CPU time: ON STasks.worker_address = SThreads.worker_address FROM sys.dm_db_index_physical_stats(DB_ID(N’AdventureWorks’), OBJECT_ Returns information about the active extended event sessions (e.g. events, actions, and targets) currently active
sys.dm_tran_current_snapshot SELECT TOP 5 total_worker_time/execution_count AS AVG_CPU_Time, WHERE STasks.session_id IS NOT NULL ID(N’AdventureWorks.Person.Address’), NULL, NULL , ‘LIMITED’); in memory.
Returns a virtual table of all active XSNs currently running when the current snapshot transaction starts. Returns no SUBSTRING(st.text, (qs.statement_start_offset/2)+1, ORDER BY STasks.session_id;
rows if the current transaction is not a snapshot transaction. ((CASE qs.statement_end_offset
WHEN -1 THEN DATALENGTH(st.text) To find if you have more currently running tasks than the maximum number of runnable tasks for the server and thus a likely
ELSE qs.statement_end_offset CPU bottleneck:
I/O
sys.dm_tran_current_transaction
Returns a single row that displays the state and snapshot sequence information of a transaction in the current END - qs.statement_start_offset)/2) + 1) AS statement_text SELECT scheduler_id,
session. Not useful for transactions running in isolation levels other than snapshot isolation level. FROM sys.dm_exec_query_stats AS qs current_tasks_count, Author, Kevin Kline
CROSS APPLY sys.dm_exec_sql_text(qs.sql_handle) AS st runnable_tasks_count
sys.dm_tran_database_transactions ORDER BY total_worker_time/execution_count DESC; FROM sys.dm_os_schedulers This section contains the following dynamic management objects. Kevin Kline has more than 18 years of experience in the IT industry
Returns information about transactions at the database level, especially transaction log information such as the log WHERE scheduler_id < 255;
sequence number (LSN), log bytes used, and transaction type. sys.dm_io_backup_tapes and is a recognized SQL Server expert. In addition to being a Microsoft
To find out if any active queries are running parallel for a given instance requires a more sophisticated query: Returns information about tape devices and the status of mount requests for backups.
SELECT r.session_id, SQL Server MVP, Kevin is a regular contributor to database technology
SQL SERVER OS
sys.dm_tran_locks
Returns information about currently active requests to the lock manager, broken into a resource group and a request r.request_id, sys.dm_io_cluster_shared_drives
group. The request status may be active, convert, or may be waiting (wait) and includes details such as the resource MAX(ISNULL(exec_context_id, 0)) as nbr_of_workers,
r.sql_handle,
Similar to fn_servershareddrives in SQL Server 2000, this DMV returns the drive name of each of the shared drives on magazines and discussion forums. Kevin is the author of the O’Reilly
on where the lock request wants a log (for the resource group) or the lock request itself (for the request group). a clustered server. Only returns data for clustered instances of SQL Server.
The following SQL Server Operating System related dynamic management views are for internal use only: sys.dm_os_ r.statement_start_offset,
r.statement_end_offset,
titles SQL in a Nutshell and Transact-SQL Programming.
sys.dm_tran_session_transactions function_symbolic_name, sys.dm_os_ring_buffers, sys.dm_os_memory_allocations, sys.dm_os_sublatches, and sys.dm_os_ sys.dm_io_pending_io_requests
Returns correlation information for associated transactions and sessions, especially useful for monitoring distributed worker_local_storage. The remaining DMVs are user-accessible and contain a panoply of information to help you understand r.plan_handle Returns one row for each pending I/O request, possibly returning large result sets on very active SQL Servers.
transactions. and manage the SQL Server Operating System (SQLOS) responsible for governing resources within the system. FROM sys.dm_exec_requests r
JOIN sys.dm_os_tasks t ON r.session_id = t.session_id sys.dm_io_virtual_file_stats
sys.dm_tran_top_version_generators sys.dm_os_buffer_descriptors JOIN sys.dm_exec_sessions s ON r.session_id = s.session_id Similar to fn_virtualfilestats in SQL Server 2000, this DMV function returns I/O statistics for data and log files for one
Returns a virtual table for the objects that are producing the most versions in the version store, as found in the Returns information about all data pages that are in the SQL Server buffer cache, excluding free, stolen, or WHERE s.is_user_process = 0x1 or all databases and one or all files within the database(s).
GROUP BY r.session_id, r.request_id, r.sql_handle, r.plan_handle,
Find all your SQL Servers in your
sys.dm_tran_version_store system view. Use with caution. This is a very resource intensive DMV. erroneously read pages. SQL Server 2005 tracks anything put into the buffer cache using buffer descriptors. You can
easily scope the results to show one or all database and one or all of the objects within the database. r.statement_start_offset, r.statement_end_offset
sys.dm_tran_transactions_snapshot HAVING MAX(ISNULL(exec_context_id, 0)) > 0
Returns invormation about active transactions when each snapshot transaction starts. Using this, you can find how sys.dm_os_child_instances
OBJECT
many snapshot transaction are currently active and identify any data modifications that are ignored by any given
snapshot transaction.
sys.dm_os_cluster_nodes
SECURITY
sys.dm_tran_version_store Returns a row for each node in the failover cluster instance configuration or an empty rowset if the server is not