Identify the SQL query causing spikes

Mike Edge 0 Reputation points
2025-01-12T17:25:00.53+00:00

Our MS SQL database in Azure runs at only a few percent DTU - except for occasional spikes to 100%. How do I find out which query is causing the spikes?

Azure SQL Database
{count} votes

1 answer

Sort by: Most helpful
  1. Erland Sommarskog 115.3K Reputation points MVP
    2025-01-12T18:37:00.07+00:00

    One way would be to set up an Extended Events session that captures statements that consumes more than a certain amount of CPU time. Given that there is some red tape with saving the data to blob storage, it is easier to use a ring buffer as a target, and that should work well under the assumption the issue is due to some occasional wild query. For more information to do that, see https://zcusa.951200.xyz/en-us/azure/azure-sql/database/xevent-code-ring-buffer?view=azuresql&tabs=sqldb

    However, it could also be matter of an application that submits a lots of shorter statements with hard-coded values, which causes a lot of compilation. This will not be detected by the X-event session I discussed, and overall it can be more difficult to track down. But start with the XE session as I suggested.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.