Simple select count(id) uses 100% of Azure SQL DTUs

前端 未结 3 1893
借酒劲吻你
借酒劲吻你 2020-12-31 06:27

This started off as this question but now seems more appropriately asked specifically since I realised it is a DTU related question.

Basically, running:



        
相关标签:
3条回答
  • 2020-12-31 06:46

    select count

    should perform clustered index scan if one is available and its up to date. Azure SQL should update statistics automatically, but does not rebuild indexes automatically if they are completely out of date.

    if there's a lot of INSERT/UPDATE/DELETE traffic on that table I suggest manually rebuilding the indexes every once in a while.

    http://blogs.msdn.com/b/dilkushp/archive/2013/07/28/fragmentation-in-sql-azure.aspx

    and SO post for more info

    SQL Azure and Indexes

    0 讨论(0)
  • 2020-12-31 06:47

    I had the same issue. Updating the statistics with fullscan on the table solved it:

    update statistics mytable with fullscan
    
    0 讨论(0)
  • 2020-12-31 06:54

    From the query stats in your previous question we can see:

    300ms CPU time
    8000 physical reads
    

    8:30 is about 500sec. We certainly are not CPU bound. 300ms CPU over 500sec is almost no utilization. We get 16 physical reads per second. That is far below what any physical disk can deliver. Also, the table is not fully cached as evidenced by the presence of physical IO.

    I'd say you are throttled. S1 corresponds to

    934 transactions per minute

    for some definition of transaction. Thats about 15 trans/sec. Maybe you are hitting a limit of one physical IO per transaction?! 15 and 16 are suspiciously similar numbers.

    Test this theory by upgrading the instance to a higher scale factor. You might find that SQL Azure Database cannot deliver the performance you want at an acceptable price.

    You also should find that repeatedly scanning half of the table results in a fast query because the allotted buffer pool seems to fit most of the table (just not all of it).

    0 讨论(0)
提交回复
热议问题