SQL Server 很慢很卡?

1、可以试着查找影响数据库性能的SQL语句

SELECT TOP 30
total_worker_time/1000 AS [CPU总耗时(ms)], 
execution_count [运行次数], 
qs.total_worker_time/qs.execution_count/1000 AS [CPU平均耗时(ms)], 
last_execution_time AS [最后执行时间], 
max_worker_time/1000 AS [最大执行耗时(ms)], 
SUBSTRING(qt.text,qs.statement_start_offset/2+1, 
 (CASE WHEN qs.statement_end_offset = -1 
 THEN DATALENGTH(qt.text) 
 ELSE qs.statement_end_offset 
 END -qs.statement_start_offset)/2 + 1) AS [SQL语句]
FROM sys.dm_exec_query_stats qs WITH(nolock)
CROSS apply sys.dm_exec_sql_text(qs.sql_handle) AS qt
WHERE execution_count > 1
ORDER BY max_worker_time DESC

https://blog.csdn.net/u011627218/article/details/127900110

SQL Server数据库阻塞,死锁,排查语句

排查运行缓慢的查询 - SQL Server | Microsoft Learn

posted @ 2024-09-11 13:40  CelonY  阅读(39)  评论(0编辑  收藏  举报