cluster nad non-cluster index

本文详细介绍了数据库中的聚簇和非聚簇索引的概念及其工作原理。聚簇索引按照键值的顺序存储数据,而非聚簇索引则独立于实际数据存储。此外还探讨了CLUSTER的优点及适用场景。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

There are clustered and nonclustered indexes.
A clustered index is a special type of index that reorders the way records in the table are physically stored. Therefore table can have only one clustered index. The leaf nodes of a clustered index contain the data pages.

A nonclustered index is a special type of index in which the logical order of the index does not match the physical stored order of the rows on disk. The leaf node of a nonclustered index does not consist of the data pages. Instead, the leaf nodes contain index rows.

 

CLUSTER是段的一种类型。一个聚簇就是一个段,聚簇中的所有表根据聚簇列存放在同一个段中。这些表具有相同的物理存储结构。

 

CLUSTER的主要优点包括:

由于不同表的数据根据CLUSTER键的顺序存放在以前,因此当对CLUSTER表之间连接访问时,会减少IO和存储访问时间;

 

虽然每个表都包含CLUSTER键,但这一列在CLUSTER中保存一份。因此可以减少存储的空间。

 

适合CLUSTER的表的特点:

 

表以查询为主,不适合以插入或修改为主的表;

 

经常通过连接一起查询的表。

 

对于索引

CLUSTER,注意首先创建CLUSTER,然后创建相应的CLUSTER表,最后一定要建立CLUSTER索引,如果不建立索引的话,没有任何记录可以插入到CLUSTER表中。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值