Query hung to SQL Server on Azure

Manish Singh 0 Reputation points
2024-09-03T12:54:37.7166667+00:00

Hi,

I have a large table (11 columns) with records around 30 million. when I am running a query

select count(ID) from

SQL Server Other
{count} votes

2 answers

Sort by: Most helpful
  1. Sina Salam 22,031 Reputation points Volunteer Moderator
    2024-09-03T13:52:12.7433333+00:00

    Hello Manish Singh,

    Welcome to the Microsoft Q&A and thank you for posting your questions here.

    I understand that your Query in SQL Server on Azure is hanging beyond consideration amount of time, and you would like to optimize it.

    To optimize your large table and improve query performance, you will have to do the rudiments and then troubleshoot slow queries either on a dedicated SQL pool or workload known issues.

    Following rudiment strategies, you will work on the followings:

    To troubleshoot slow queries performance:

    Check the above topics suitable for your server environment as it's listed in the additional resources by the right side of this page.

    I hope this is helpful! Do not hesitate to let me know if you have any other questions.

    ** Please don't forget to close up the thread here by upvoting and accept it as an answer if it is helpful ** so that others in the community facing similar issues can easily find the solution.

    Best Regards,

    Sina Salam

    0 comments No comments

  2. Erland Sommarskog 121.4K Reputation points MVP Volunteer Moderator
    2024-09-03T21:26:38.0366667+00:00

    Which service tier do you have?

    Blocking could be a possible reason. Make note of the spid of the window where you run the query (you see it in the status bar), then in a second window in the same database run

    SELECT * FROM sys.dm_os_waiting_tasks WHERE session_id = <spid>
    

    Is there any data in the column blocking_session_id? What is the wait type?

    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.