get the top-10 queries that are taking the most CPU per execution
2010-06-09 15:34
323 查看
1.
SELECT TOP 10 total_worker_time/execution_count AS avg_cpu_cost, plan_handle, execution_count, (SELECT SUBSTRING(text, statement_start_offset/2 + 1, (CASE WHEN statement_end_offset = -1 THEN LEN(CONVERT(nvarchar(max), text)) * 2 ELSE statement_end_offset END - statement_start_offset)/2) FROM sys.dm_exec_sql_text(sql_handle)) AS query_text FROM sys.dm_exec_query_stats ORDER BY [avg_cpu_cost] DESC
If you use the above DMV, you may miss finding the most frequently executed queries in your workload if the CPU cost of those queries is much less than say top-10 queries. To find the most frequently executed queries in your workload, you can execute the following DMV query, a slight variant of the previous DMV query:
2.
SELECT TOP 10 total_worker_time, plan_handle,execution_count, (SELECT SUBSTRING(text, statement_start_offset/2 + 1, (CASE WHEN statement_end_offset = -1 THEN LEN(CONVERT(nvarchar(max),text)) * 2 ELSE statement_end_offset END - statement_start_offset)/2) FROM sys.dm_exec_sql_text(sql_handle)) AS query_text FROM sys.dm_exec_query_stats ORDER BY execution_count DESC
相关文章推荐
- get the top-10 queries that are taking the most CPU
- find the top-10 queries that do the most I/Os per execution
- find the top-10 query plans that have been recompiled the most.
- What are the top 10 things that we should be informed about in life
- 【MySQL笔记】解除输入的安全模式,Error Code: 1175. You are using safe update mode and you tried to update a table without a WHERE that uses a KEY column To disable safe mode, toggle the option in Preferences -> SQL Queries and reconnect.
- The most popular (i.e., the most visited) websites have in common that they are dynamic websites. Th
- MS SQL2005 How to find the top 50 cpu execution time.
- The 10 most important things are…
- identify internal components that are stealing the most pages from buffer pool using the following DMV query
- ling join 报错The specified LINQ expression contains references to queries that are associated with different cont
- The specified LINQ expression contains references to queries that are associated with different contexts
- Use Tab twice to get the code snippets that are available within code editor
- [Maven in action] 解决办法:Could not get the value for parameter encoding for plugin execution...
- These are the problems and solutions that I discovered while writing my first Cocoa program for Mac
- There are no resources that can be added or removed from the server. .
- The 10 Most Important Security Controls Missing in JavaEE--reference
- 在PL/SQL DEV里面有把锁一样的按钮,点击它为什么会跳出“these query result are not updateable,include the ROWID to get updateable results”
- around thThe usual answers we get are "competitive
- How can selenium web driver get to know when the new window has opened and then resume its execution
- HOW TO: Tune and Scale Performance of Applications That Are Built on the .NET Framework -zt from MS