“select count(id) from table” takes up to 30 minutes to calculate in SQL Azure

前端 未结 3 1311
野趣味
野趣味 2021-02-07 04:30

I have a database in SQL Azure which is not taking between 15 and 30 minutes to do a simple:

select count(id) from mytable

The database is abou

3条回答
  •  攒了一身酷
    2021-02-07 05:11

    Quick refinement of @FoggyDay post. If your tables are partitioned, you'll want to sum the rowcount.

    SELECT t.name, SUM(s.row_count) row_count
    FROM sys.tables t
    JOIN sys.dm_db_partition_stats s
    ON t.object_id = s.object_id
      AND t.type_desc = 'USER_TABLE'
      AND t.name not like '%dss%'
      AND s.index_id = 1
    GROUP BY t.name
    

提交回复
热议问题