SQL Performance – Finding total elapsed time
One of the key tasks of a database administrator is to ensure that the SQL Server database is running efficiently and effectively. One way to do this is by using performance tuning techniques, which can help identify and resolve any performance bottlenecks or issues in the database.
One performance tuning tip for SQL Server is to use the sys.dm_exec_query_stats dynamic management view (DMV). This DMV provides detailed information about the performance of queries that have been executed in the database, including the execution count, the total elapsed time, the average elapsed time, and the total number of rows returned.
To use the sys.dm_exec_query_stats DMV, you can run the following query:
SELECT * FROM sys.dm_exec_query_stats ORDER BY total_elapsed_time DESC;
This query returns all the columns from the sys.dm_exec_query_stats DMV, sorted in descending order by the total_elapsed_time column. This allows you to see the most expensive queries in terms of elapsed time, which are the queries that are potentially causing performance issues.
Once you have identified the most expensive queries, you can use the information in the sys.dm_exec_query_stats DMV, along with other tools and techniques, to troubleshoot and optimize the queries. For example, you can use the sys.dm_exec_query_plan DMV to view the execution plan for a query, and you can use the SET STATISTICS TIME and SET STATISTICS IO commands to get more detailed information about the query performance.
Another option is to use Database Health Monitor, our monitoring solution for SQL Server
More from Stedman Solutions:
Steve and the team at Stedman Solutions are here for all your SQL Server needs.
Contact us today for your free 30 minute consultation..
We are ready to help!
Leave a Reply