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

标签 sql sql-server tsql sql-server-2014

在内存优化表中创建哈希索引时,我可以设置变量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 the number of distinct values in the index key. If the index key contains a lot of duplicate values, on average there are more than 10 rows for each 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/

相关文章:

sql - 客户端 PC 上的应用程序在 1 年后过期,客户端 PC 上没有互联网可用

java - Hibernate获取SQL query.list() : ArrayIndexOutOfBoundsException 0

sql-server - 无法解决 SELECT 语句中第 4 列的排序规则冲突

sql - (通用表表达式)CTE 作为 WHERE 子句的一部分......可能吗?

SQL Server 查询以对连续日期进行分组

SQL 查询在 SQL Server 2012 中运行良好,但在 SQL Server 2008 R2 中无法执行

sql - 在sql中,长度函数是O(1)还是O(length)

sql - 在 SQL 中选择具有多个 GROUP 的表中 TOP 2 值的 SUM

mysql - 如何计算名字以a,b,c......开头的员工的sal?

sql - 尝试将动态 SQL 子查询结果放入 SQL-Server 2008 临时表而不预先定义临时表