WITH TMP AS
(
SELECT TOP 100
CAST(SUM(s.total_elapsed_time) / 1000000.0 AS DECIMAL(10, 2)) AS [Total Elapsed Time in S],
SUM(s.execution_count) AS [Total Execution Count],
CAST(SUM(s.total_worker_time) / 1000000.0 AS DECIMAL(10, 2)) AS [Total CPU Time in S],
CAST(SUM(s.total_worker_time) / SUM(s.execution_count) / 1000.0 AS DECIMAL(10, 2)) AS [Avg CPU Time in MS],
SUM(s.total_logical_reads) AS [Total Logical Reads],
CAST(CAST(SUM(s.total_logical_reads) AS FLOAT) / CAST(SUM(s.execution_count) AS FLOAT) AS DECIMAL(10, 2)) AS [Avg Logical Reads],
SUM(s.total_logical_writes) AS [Total Logical Writes],
CAST(CAST(SUM(s.total_logical_writes) AS FLOAT) / CAST(SUM(s.execution_count) AS FLOAT) AS DECIMAL(10, 2)) AS [Avg Logical Writes],
SUM(s.total_clr_time) AS [Total CLR Time],
CAST(SUM(s.total_clr_time) / SUM(s.execution_count) / 1000.0 AS DECIMAL(10, 2)) AS [Avg CLR Time in MS],
CAST(SUM(s.min_worker_time) / 1000.0 AS DECIMAL(10, 2)) AS [Min CPU Time in MS],
CAST(SUM(s.max_worker_time) / 1000.0 AS DECIMAL(10, 2)) AS [Max CPU Time in MS],
SUM(s.min_logical_reads) AS [Min Logical Reads],
SUM(s.max_logical_reads) AS [Max Logical Reads],
SUM(s.min_logical_writes) AS [Min Logical Writes],
SUM(s.max_logical_writes) AS [Max Logical Writes],
CAST(SUM(s.min_clr_time) / 1000.0 AS DECIMAL(10, 2)) AS [Min CLR Time in MS],
CAST(SUM(s.max_clr_time) / 1000.0 AS DECIMAL(10, 2)) AS [Max CLR Time in MS],
COUNT(1) AS [Number of Statements],
MAX(s.last_execution_time) AS [Last Execution Time],
s.plan_handle AS [Plan Handle]
FROM
sys.dm_exec_query_stats s --Most CPU consuming
GROUP BY s.plan_handle ORDER BY SUM(s.total_worker_time) DESC -- Most read+write IO consuming
--GROUP BY s.plan_handle ORDER BY SUM(s.total_logical_reads + s.total_logical_writes) DESC -- Most write IO consuming
--GROUP BY s.plan_handle ORDER BY SUM(s.total_logical_writes) DESC -- Most CLR consuming
--WHERE s.total_clr_time > 0 GROUP BY s.plan_handle ORDER BY SUM(s.total_clr_time) DESC
)
SELECT
TMP.*,
st.text AS [Query],
qp.query_plan AS [Plan]
FROM
TMP
OUTER APPLY
sys.dm_exec_query_plan(TMP.[Plan Handle]) AS qp
OUTER APPLY
sys.dm_exec_sql_text(TMP.[Plan Handle]) AS st

  

Worst Performing Queries的更多相关文章

  1. [转]Raw Queries in Laravel

    本文转自:https://fideloper.com/laravel-raw-queries Business logic is often complicated. Because of this, ...

  2. 如何找出你性能最差的SQL Server查询

    我经常会被反复问到这样的问题:”我有一个性能很差的SQL Server.我如何找出最差性能的查询?“.因此在今天的文章里会给你一些让你很容易找到问题答案的信息向导. 问SQL Server! SQL ...

  3. SQL Server 日常维护经典应用

    SQL Server日常维护常用的一些脚本整理. 1.sql server开启clr权限: GO RECONFIGURE GO ALTER DATABASE HWMESTC SET TRUSTWORT ...

  4. 【转】php容易犯错的10个地方

    原文地址: http://www.toptal.com/php/10-most-common-mistakes-php-programmers-make 译文地址:http://codecloud.n ...

  5. [转]Performance Analysis Using SQL Server 2008 Activity Monitor Tool

    本文转自:https://www.mssqltips.com/sqlservertip/1917/performance-analysis-using-sql-server-2008-activity ...

  6. (转) Written Memories: Understanding, Deriving and Extending the LSTM

    R2RT   Written Memories: Understanding, Deriving and Extending the LSTM Tue 26 July 2016 When I was ...

  7. nodejs应用mysql(纯属翻译)

    原文点击这里 目录 Install Introduction Contributors Sponsors Community Establishing connections Connection o ...

  8. PHP foreach 遍历数组是打印出相同的数据

    https://www.toptal.com/php/10-most-common-mistakes-php-programmers-make PHP makes it relatively easy ...

  9. KoaHub.JS基于Node.js开发的mysql的node.js驱动程序代码

    mysql A node.js driver for mysql. It is written in JavaScript, does not require compiling, and is 10 ...

随机推荐

  1. Landpy.ActiveDirecoty,按照Active Record Pattern设计的方便Lib开源发布

    想方便的操作AD吗,不想记住那么多AD Attribute名称和常量?请使用Landpy.ActiveDirecoty库,按照Active Record Pattern设计的AD Lib已经在Code ...

  2. oracle 存储过程 where in参数传入问题

    问题: 举个简单例子说明create or replace procedure procStr(inString in varchar2)asbeginselect * from book where ...

  3. 扁平化你的Qt应用程序

    什么是扁平化 这里的扁平化指的是交互设计方面的一种风格. 扁平化是随着极简注意的风潮流行起来的,这个概念最核心的地方就是放弃一切装饰效果,诸如阴影.透视,纹理,渐变等等能做出3D效果的元素一概不用.全 ...

  4. nyoj-655-光棍的yy(大数)

    光棍的yy 时间限制:1000 ms  |  内存限制:65535 KB 难度:2 描写叙述 yy常常遇见一个奇怪的事情.每当他看时间的时候总会看见11:11,这个非常纠结啊. 如今给你m个1,你能够 ...

  5. Effective C++ Item 33 Avoid hiding inherited names

    class Base { private: int x; public: ; virtual void mf2(); void mf3(); ... }; class Derived: public ...

  6. ios开发之--ios11适配:TableView的heightForHeaderInSection设置高度无效/UISearchBar消失

    更新到ios11,然后使用x-code9运行项目,发现tableview的-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInS ...

  7. POST提交表单,本地Windows测试无乱码,而将项目部署到服务器端产生乱码原因之一

    项目在Windows机上eclipse发布至tomcat测试没有问题,表单提交到数据库的中文都能正常显示,而将项目部署到服务器上时,出现中文乱码 确认POST提交都使用了request.setChar ...

  8. Google Inc.:Google APIs:23' 解决方案

    在导入一个项目是,出现 Unable to resolve target 'Google Inc.:Google APIs:6'第一种解决方法: compileSdkVersion 23 改成 com ...

  9. stl中的map经验

    如果想使用一个map临时变量装载参数map,不需要使用new创建一个对象. 声明一个变量,直接赋值就可以.map内部自己重载了=操作符,会自己分配内存.

  10. 《转》python学习(9)字典

    转自 http://www.cnblogs.com/BeginMan/p/3156960.html 一.映射类型 我理解中的映射类型是:键值对的关系,键(key)映射值(value),且它们是一对多的 ...