gpt4 book ai didi

sql-server - SQL Server : 12% index scan density and 50% fragmentation. "bad"有多糟糕?

转载 作者:行者123 更新时间:2023-12-04 06:12:03 26 4
gpt4 key购买 nike

多少碎片是坏的?扫描密度太低有多低?
扫描密度有多低是不好的?

我有一个具有以下索引密度和碎片级别的表:

Name                           Scan Density  Logical Fragmentation
============================= ============ =====================
IX_TransactionEntries_Tran... 12.834 48.392
IX_TransactionEntries_Curr... 15.419 41.239
IX_TransactionEntries_Tran... 12.875 48.372
TransactionEntries17 98.081 0.0049325
TransactionEntries5 12.960 48.180
PK_TransactionEntries 12.869 48.376
TransactionEntries18 12.886 48.480
IX_TranasctionEntries_CDR... 12.799 49.157
IX_TransactionEntries_CDR... 12.969 48.103
IX_TransactionEntries_Tra... 13.181 47.127

你可以看到我刚刚整理了碎片 TransactionEntries17 ,这就是为什么它的 扫描密度 这么高,是 碎片化这么低。

但是 12% 的扫描密度低得可怕吗? 48% 的碎片化程度高得可怕吗?

我收到 performance issues when deleting rows (这需要索引扫描)。索引碎片是否为 巨型闪烁红色警报在 70000 页索引上,还是可能但不太可能的原因?

从 SQL Server BOL:

Scan Density [Best Count: Actual Count]

Is a percentage. It is the ratio Best Count to Actual Count. This value is 100 if everything is contiguous; if this value is less than 100, some fragmentation exists.

Best Count is the ideal number of extent changes if everything is contiguously linked. Actual Count is the actual number of extent changes.

LogicalFragmentation

Percentage of out-of-order pages returned from scanning the leaf pages of an index. This number is not relevant to heaps. An out-of-order page is a page for which the next physical page allocated to the index is not the page pointed to by the next-page pointer in the current leaf page.



但是没有关于什么程度的碎片化太高,应该减少的指导。也没有任何关于什么扫描密度太低,应该增加的指导。

最佳答案

与 SQL 中的其他任何内容一样,看情况 .

这将取决于诸如争用之类的东西(这会增加等待时间,因为有更多的数据页要“争用”)、索引的宽度等等等等。

根据我的个人经验,我对碎片化对我运行的某些构建和负载的影响进行了一些测试。

对于聚合密集型过程,我对碎片率为 40% 的表进行了一次运行,对碎片率为 0% 的“相同”表运行了另一次。

40% 的碎片表占用了 延长 1,200% 运行相同的基本操作。

您的里程可能会有所不同,但这会产生很大的不同。

Paul Randal, arguably responsible for most of DBCC in SQL Server 2005+, thinks its a pretty huge deal too.

简而言之,唯一确定的方法就是进行测试。 BOL 没有给出密度和碎片范围的指南,因为变量太多,无法进行“一般”评估。

这就像问“我的车是不是太损坏了?”答案取决于“损坏的原因是什么?”、您驾驶的距离、速度、在什么样的道路上、什么样的天气、一年中的什么时间,以及其他一百万件事。

关于sql-server - SQL Server : 12% index scan density and 50% fragmentation. "bad"有多糟糕?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7666642/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com