Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

关于dbengine使用聚簇索引和二级索引方式的建议 #47

Closed
EzioZz opened this issue Nov 27, 2020 · 2 comments
Closed

关于dbengine使用聚簇索引和二级索引方式的建议 #47

EzioZz opened this issue Nov 27, 2020 · 2 comments
Assignees

Comments

@EzioZz
Copy link
Contributor

EzioZz commented Nov 27, 2020

NMSQL中分为两种索引:聚簇索引(clustered index)和次要索引(secondary index)。这两种索引都是一种差不多的B+树。

一张表有且只有一个聚簇索引,也就是只有一个主键(虽然主键是一个逻辑上的概念,这里先这么叫)。主键会决定了数据的真实存储位置。次要索引可以有很多,不会影响数据的实际存储位置。

dbengine使用B+Tree接口的时候需要注意以下几点:

  1. 如果用户没有指定建立一个聚簇索引,那么dbengine需要创建一个虚拟的主键,用于聚簇。
  2. 聚簇索引的lead node存的是真实的数据,而次要索引存的leaf node存的data是用于聚簇的主键(不直接存row pointer是为了减少节点合并和分裂时候的开销)。
  3. 对一张表进行操作的时候,要对所以的索引进行同步的操作。

@osmium18452

@osmium18452
Copy link
Contributor

等我吃完饭看看

@osmium18452
Copy link
Contributor

Roger

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants