转自: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.

[转]SQL SERVER – Find Most Expensive Queries Using DMV相关推荐

  1. query登录linux命令,在Linux系统中使用sqlcmd命令连接与查询SQL Server

    本文根据微软官方手册整理完成 This topic provides connection requirements and guidance for SQL Server vNext CTP 1.3 ...

  2. sql server新增列_SQL Server 2017中的新增功能

    sql server新增列 SQL Server 2017 is considered a major release in the history of the SQL Server life cy ...

  3. SQL Server安装程序–数据库警报

    为什么要启用警报 (Why should you enable alerts) While the article "How to create and configure SQL Serv ...

  4. sql server分页_SQL Server中的分页简介

    sql server分页 Wikipedia Pagination is the process of dividing content (i.e. website search results, n ...

  5. Microsoft SQL Server数据库部署过程

    介绍 (Introduction) Database deployments are critical tasks that can affect negative in on performance ...

  6. 如何在SQL Server中分析存储子系统性能

    介绍 (Introduction) To improve performance, it is common for DBAs to search in each aspect except anal ...

  7. sql server 缓存_深入了解SQL Server缓冲区缓存

    sql server 缓存 When we talk about memory usage in SQL Server, we are often referring to the buffer ca ...

  8. SQL Server商业智能功能–创建简单的OLAP多维数据集

    介绍 (Introduction) 多维多维数据集和事务数据库是两个非常不同的事物. 从经验中,我什至是经验丰富的DBA都完全避免使用多维数据集这一主题,因为对于他们而言,多维数据集实在是一个未知领域 ...

  9. sql server 锁定_关于锁定SQL Server的全部

    sql server 锁定 .SQLCode { font-size: 13px; font-weight: bold; font-family: monospace;; white-space: p ...

最新文章

  1. discoGAN 论文解读
  2. Html做网络硬盘系统交互,教你做网络硬盘(上)
  3. 推荐《求医不如求己》,实用
  4. vant 做表格_Vant List 列表
  5. 移动建模平台元数据存储架构演进
  6. Mvvm、第一个Vue程序、Vue基本语法
  7. 小米宣布新一轮组织架构调整,崔宝秋挂帅技术委员会
  8. PLC控制系统设计的基本原则和主要内容
  9. 使用Dependency Walker对模块进行故障排除
  10. 【干货分享】花坊类字体设计思路
  11. 数字逻辑课程设计--数字钟的设计(quartus ii)(内附源代码和实习报告以及6篇实习日志)
  12. pyspark运行ALS推荐算法
  13. 程序员应知必会的思维模型之 22 奥卡姆剃刀 (Occam‘s Razor)
  14. 卐 4-3D图形的数学
  15. 学习新手给Android新手的一些学习建议
  16. 基于Python的QQ音乐音频图片搜索系统设计与实现 毕业论文+源码
  17. History lives on in this distinguished Polish city 2017/1/4
  18. java获取货币汇率_JAVA抓取中国外汇交易中心各币别对RMB汇率
  19. bin文件是如何读取的
  20. android/iphone/windows/linux/微信声波通讯库

热门文章

  1. android 开启一个定时线程_Android异步、延迟和定时任务的简易用法
  2. 2021物理大事汇:μ子磁性异常,时间晶体现身,天体物理大丰收
  3. 魔改GPT自动写网文,速度一秒十字,还能给太监作品无限续更 | 开源
  4. 云计算的未来,就是“打车模式” | CCF C³@亚马逊云科技
  5. 华为计算黄之鹏:AI开源框架已经到“汽车替代马车”的阶段 | MEET2021
  6. 按AI顶会评实力:美国7倍领先中国,谷歌雄霸全球第一,腾讯和清华分获中国产学No.1...
  7. 高清还原破损视频,参数和训练时间减少三分之二,台大这项研究登上了BMVC 2019...
  8. C++ 继承与接口 知识点 小结(一)
  9. 工作流引擎Oozie(一):workflow
  10. varnish配置详解