简体   繁体   English

azure 托管实例 sql server 数据库上的基本查询非常慢

[英]basic query very slow on azure managed instance sql server database

On an Azure managed sql server instance database, I do在 Azure 托管的 sql server 实例数据库上,我做

Select top 1000 * from _CSP_Detail.

The data table is empty because I deleted all data from the table yesterday (Delete * from _CSP_Detail).数据表是空的,因为我昨天从表中删除了所有数据(Delete * from _CSP_Detail)。
It used to have a million rows, and it took a while to delete.它曾经有一百万行,删除需要一段时间。 There are a hand full of indexes / indices defined on the table.表上定义了满满一手的索引/索引。

After doing the delete, today, I am finding that删除后,今天,我发现

Select top 1000 * from _CSP_Detail

does pull nothing, as expected, but takes over a minute to run.正如预期的那样,什么都不拉,但需要一分钟多的时间才能运行。

Puzzled.困惑。 Any ideas?有任何想法吗?

It seems your table is a heap (no clustered index).看来你的表是一个堆(没有聚集索引)。 Space is not reclaimed when you delete rows from a heap so, even though the table is empty, the allocated pages must be scanned by the SELECT query to find rows.从堆中删除行时不会回收空间,因此即使表为空,也必须通过SELECT查询扫描分配的页面以查找行。

Explicitly TRUNCATE the table or create/drop a clustered index to reclaim space and improve performance against the empty table.显式TRUNCATE表或创建/删除聚集索引以回收空间并提高针对空表的性能。

Note that tables should generally have a clustered index according to the documentation .请注意,根据文档,表通常应具有聚集索引。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM