SQL 稀疏索引和密集索引的区别
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/36808877/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Difference between sparse index and dense index
提问by Sabir Al Fateh
I am very confused to understand the difference between sparse index and dense index. Can you explain the difference between them ?
我很困惑理解稀疏索引和密集索引之间的区别。你能解释一下它们之间的区别吗?
回答by Abhinav Srivastava
As described in this link
如此链接中所述
Dense Index:
- An index record appears for every search key value in file.
- This record contains search key value and a pointer to the actual record.
Sparse Index:
- Index records are created only for some of the records.
- To locate a record, we find the index record with the largest search key value less than or equal to the search key value we are looking for.
- We start at that record pointed to by the index record, and proceed along the pointers in the file (that is, sequentially) until we find the desired record.
密集指数:
- 文件中的每个搜索键值都会出现一个索引记录。
- 该记录包含搜索键值和指向实际记录的指针。
稀疏索引:
- 仅为部分记录创建索引记录。
- 为了定位一条记录,我们找到最大搜索键值小于或等于我们要查找的搜索键值的索引记录。
- 我们从索引记录指向的那条记录开始,沿着文件中的指针(即顺序)继续,直到找到所需的记录。
Also, dense indicesare fasterin general, but sparse indicesrequire less spaceand impose less maintenancefor insertions and deletions
此外,密集索引通常更快,但稀疏索引需要更少的空间并且对插入和删除的维护更少
回答by Abhinav Srivastava
In Dense Index, an index entry appears for every search-key whereas for Sparse index, an index entry appears for only some of the search-key values.
在密集索引中,每个搜索键都会出现一个索引条目,而对于稀疏索引,索引条目只出现在某些搜索键值上。