How To Get A List Of Top CPU Consuming T-SQL Queries

Photo by Caspar Camille Rubin on Unsplash

In this post, I’ll be referring to MS SQL Server as SQL Server

A lot of times the SQL Server uses a lot of resources causing strange CPU spikes.

Though these are meant to be there so that SQL server can provide more optimized performance, they can be a bottleneck if we see a long spike or continuous spikes.

We therefore need to figure out what query is responsible so that we can then optimize it.

To figure this out, you need to follow the following steps

SELECT sqltext.TEXT,
FROM sys.dm_exec_requests req
CROSS APPLY sys.dm_exec_sql_text(sql_handle) AS sqltext
ORDER BY req.cpu_time DESC



DevOps | Creator | Learner

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store