zoukankan      html  css  js  c++  java
  • [转]SQL SERVER – Find Most Expensive Queries Using DMV

    转自:http://blog.sqlauthority.com/2010/05/14/sql-server-find-most-expensive-queries-using-dmv/

    The title of this post is what I can express here for this quick blog post. I was asked in recent query tuning consultation project, if I can share my script which I use to figure out which is the most expensive queries are running on SQL Server. This script is very basic and very simple, there are many different versions are available online. This basic script does do the job which I expect to do – find out the most expensive queries on SQL Server Box.

    SELECT TOP 10 SUBSTRING(qt.TEXT, (qs.statement_start_offset/2)+1,
    ((CASE qs.statement_end_offset
    WHEN -1 THEN DATALENGTH(qt.TEXT)
    ELSE qs.statement_end_offset
    END - qs.statement_start_offset)/2)+1),
    qs.execution_count,
    qs.total_logical_reads, qs.last_logical_reads,
    qs.total_logical_writes, qs.last_logical_writes,
    qs.total_worker_time,
    qs.last_worker_time,
    qs.total_elapsed_time/1000000 total_elapsed_time_in_S,
    qs.last_elapsed_time/1000000 last_elapsed_time_in_S,
    qs.last_execution_time,
    qp.query_plan
    FROM sys.dm_exec_query_stats qs
    CROSS APPLY sys.dm_exec_sql_text(qs.sql_handle) qt
    CROSS APPLY sys.dm_exec_query_plan(qs.plan_handle) qp
    ORDER BY qs.total_logical_reads DESC -- logical reads
    -- ORDER BY qs.total_logical_writes DESC -- logical writes
    -- ORDER BY qs.total_worker_time DESC -- CPU time

    You can change the ORDER BY clause to order this table with different parameters. I invite my reader to share their scripts.

  • 相关阅读:
    Java在linux环境下和windows环境下日期字符串显示不同
    PPT制作手机手指滑动效果
    linux segmentation fault记录
    Linux SDK之uClinux、Broadcom、Atheros、Realtek、Ralink、Marvell、Intel
    chrome保存网页为单个文件(mht格式)
    解决liblzo2.so缺失
    What is uClinux?
    linux(CentOS5.8)环境下搭建Radius
    去除快捷方式小箭头
    【转载】ssh(安全外壳协议)
  • 原文地址:https://www.cnblogs.com/icyJ/p/5164047.html
Copyright © 2011-2022 走看看