Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Building diagnostic queries using DMVs and DMFs

234 views

Published on

Building diagnostic queries using DMVs and DMFs
Greek MVPs in Action
Virtual Event
Mar 29, 2020

Published in: Data & Analytics
  • Be the first to comment

  • Be the first to like this

Building diagnostic queries using DMVs and DMFs

  1. 1. Building Diagnostic Queries Using DMVs and DMFs Greek MVPs in Action Virtual Event Mar 29, 2020
  2. 2. Please mute your mic
  3. 3. Antonios Chatzipavlis Data Solutions Consultant & Trainer Since 1999 30+Years in a Field 20+ Experience with 60+ Certifications SQLschool.gr Founder
  4. 4. 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
  5. 5. Connect / Explore / Learn 10 Celebrating 2010-2020 years
  6. 6. Presentation Content Building Diagnostic Queries Using DMVs and DMFs • What is DMVs/DMFs • Query Execution DMVs/DMFs • Query Plan cache DMVs/DMFs • Troubleshooting with DMVs/DMFs
  7. 7. • 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
  8. 8. • 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
  9. 9. • 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
  10. 10. Demonstration Troubleshooting with DMVs/DMFs
  11. 11. Any questions
  12. 12. Thank you! @antoniosch - @sqlschool ./sqlschoolgr - ./groups/sqlschool ./c/SqlschoolGr SQLschool.gr Group Antonios Chatzipavlis Data Solutions Consultant & Trainer
  13. 13. A community for Greek professionals who use the Microsoft Data Platform Copyright © SQLschool.gr. All right reserved. PRESENTER MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION

×