Index & B+ tree

2020-04-15  本文已影响0人  ZzzZBbbB

Index

An index is a data structure that speeds up selections on the search key field(s)

Search key:any subset of the fields of a relation
the search key is not the same as the key(minimal set of fields that uniquely identify a record in a relation).

Entries in an index: (k, r)
k: search key
r: records or record ids

Index分类:

search key 分类:

for different queries, the index can be useful or useless

index performance.png

B+ tree

B+ tree is a data structure that helps search data, it is often used in DBMS or file system

结构:

root, internal node, leaf node

Before splitting for a leaf node.png

After split, 5 keys and 7 pointers


After splitting for a leaf node.png

Before splitting an internal node, there are 5 keys and 6 pointers;
After splitting, there are still 5 keys and 6 pointers


spliiting an internal node.png

Insertion cascaded:
splitting a leaf node may lead to splitting of its parent and ancestors.

B+ tree 上index的删除

Deletion is the opposite operation of insertion
risk: underflow
strategy: merging

-If a node is below the min capacity after deletion, which is producing underflow, try the following in the given order

  1. move a key from an immediate left sibling;
  2. move a key from an immediate right sibling;
  3. merge with an immediate left sibling;
  4. merge with an immediate right sibling
上一篇下一篇

猜你喜欢

热点阅读