gpt4 book ai didi

SQL Server 内存中 OLTP 哈希索引设置 BUCKET_COUNT 值

转载 作者:行者123 更新时间:2023-12-03 00:21:53 24 4
gpt4 key购买 nike

在内存优化表中创建哈希索引时,我可以设置变量BUCKET_COUNT的值

CREATE TABLE [Table1] (
[Id] INT NOT NULL IDENTITY(1,1) PRIMARY KEY NONCLUSTERED HASH
WITH (BUCKET_COUNT = 1000000),
[Name] NVARCHAR(100) NOT NULL
)
WITH (MEMORY_OPTIMIZED = ON, DURABILITY = SCHEMA_AND_DATA);

该变量的最佳值是多少?

最佳答案

根据Determining the Correct Bucket Count for Hash Indexes :

In most cases the bucket count should be between 1 and 2 times thenumber of distinct values in the index key. If the index key containsa lot of duplicate values, on average there are more than 10 rows foreach index key value, use a nonclustered index instead

You may not always be able to predict how many values a particular index key may have or will have. Performance should be acceptable if the BUCKET_COUNT value is within 5 times of the actual number of key values.

还有:

Primary Key and Unique Indexes

Because the primary key index is unique, the number of distinct values in the key corresponds to the number of rows in the table.

关于SQL Server 内存中 OLTP 哈希索引设置 BUCKET_COUNT 值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36639140/

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