说明:仅支持sql server2008及以上版本
通过下面的SQL语句可以查看Sqlserver执行的SQL记录,常用于SQL优化及辅助查找数据更新相关功能bug。
1 SELECT TOP 1000 2 ST.text AS '执行的SQL语句', 3 QS.execution_count AS '执行次数', 4 QS.total_elapsed_time AS '耗时', 5 QS.total_logical_reads AS '逻辑读取次数', 6 QS.total_logical_writes AS '逻辑写入次数', 7 QS.total_physical_reads AS '物理读取次数', 8 QS.creation_time AS '执行时间' , 9 QS.* 10 FROM sys.dm_exec_query_stats QS 11 CROSS APPLY 12 sys.dm_exec_sql_text(QS.sql_handle) ST 13 WHERE QS.creation_time >'2020-08-18' 14 ORDER BY 15 QS.total_elapsed_time DESCView Code ————————————————
版权声明:本文为CSDN博主「zsw119」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/zsw119/article/details/129282089 标签:QS,执行,SQL,SQLServer,查询,sql,time,total From: https://www.cnblogs.com/topboy168/p/17268229.html