5. Antonios Chatzipavlis
Data Solutions Consultant & Trainer
Since 1999
30+Years in a Field
20+
Experience with
60+
Certifications
SQLschool.gr
Founder
6. A community for Greek professionals who use the
Microsoft Data Platform
Connect / Explore / Learn
@antoniosch - @sqlschool
./sqlschoolgr - ./groups/sqlschool
yt/c/SqlschoolGr
SQLschool.gr Group
help@sqlschool.gr
Join us
Articles
SQL Saturday Nights
SQL Server in Greek
Webcasts
News
Resources
10. • DMVs and DMFs return server-state
information
- They are virtual objects that return state
information
- The state is cleared when the server
instance is restarted or an administrator
clears the state information.
• Can be used
- monitor the health of a server instance
- diagnose problems
- tune performance
• Two types:
- Server-scoped—require VIEW SERVER
STATE permission
- Database-scoped—require VIEW
DATABASE STATE permission
• All DMVs and DMFs exist in the sys
schema and follow the naming
convention dm_%.
- They are defined in the resource database
and are mapped to other databases.
What is DMVs/DMFs
Introduced as a new concept in SQL Server 2005
11. • sys.dm_exec_sessions (DMV)
- Returns one row per authenticated session
on SQL Server, shows information about
all active user connections and internal
tasks
• sys.dm_exec_requests (DMV)
- Returns information about each request
that is executing in SQL Server
• sys.dm_exec_sql_text (DMF)
- Returns the text of the SQL batch that is
identified by the specified sql_handle
• sys.dm_exec_input_buffer (DMF)
- Returns information about statements
submitted to an instance of SQL Server.
• sys.dm_os_waiting_tasks (DMV)
- Returns information about the wait queue
of tasks that are waiting on some
resource.
Query Execution DMVs/DMFs
The most common Query Execution DMVs/DMFs in usage
12. • sys.dm_exec_query_stats (DMV)
- Returns aggregate performance statistics
for cached query plans in SQL Server.
• sys.dm_exec_query_plan (DMF)
- 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.
• sys.dm_exec_cached_plans (DMV)
- Returns a row for each query plan that is
cached by SQL Server for faster query
execution.
• sys.dm_exec_procedure_stats (DMV)
- Returns aggregate performance statistics
for cached stored procedures.
• sys.dm_exec_function_stats (DMV)
- Returns aggregate performance statistics
for cached functions.
• sys.dm_exec_trigger_stats
- Returns aggregate performance statistics
for cached triggers.
Query Plan cache DMVs/DMFs
Provide information about queries that are currently in the plan cache