方法一:
方法二:
使用以下语句查找出什么语句占内存最高,针对占内存高的语句进行优化
SELECT SS.SUM_EXECUTION_COUNT,
T.TEXT,
SS.SUM_TOTAL_ELAPSED_TIME AS \'总和时间\',
SS.SUM_TOTAL_WORKER_TIME AS \'执行耗时\',
SS.SUM_TOTAL_LOGICAL_READS AS \'总和逻辑读数\',
SS.SUM_TOTAL_LOGICAL_WRITES AS \'总和逻辑写\'
FROM (SELECT S.PLAN_HANDLE,
SUM(S.EXECUTION_COUNT)SUM_EXECUTION_COUNT,
SUM(S.TOTAL_ELAPSED_TIME)SUM_TOTAL_ELAPSED_TIME,
SUM(S.TOTAL_WORKER_TIME)SUM_TOTAL_WORKER_TIME,
SUM(S.TOTAL_LOGICAL_READS)SUM_TOTAL_LOGICAL_READS,
SUM(S.TOTAL_LOGICAL_WRITES)SUM_TOTAL_LOGICAL_WRITES
FROM SYS.DM_EXEC_QUERY_STATS S
GROUP BY S.PLAN_HANDLE
) AS SS
CROSS APPLY SYS.dm_exec_sql_text(SS.PLAN_HANDLE)T
ORDER BY SUM_TOTAL_LOGICAL_READS DESC
https://msdn.microsoft.com/zh-cn/library/ms189741(v=sql.110).aspx //说明:SYS.DM_EXEC_QUERY_STATS