When to split/merge B-Tree nodes?
Posted: Fri Dec 21, 2012 10:41 am
Hi,
in a traditional B-Tree a node is split when it has n+1 entries (when it is over full) producing 2 nodes with n/2 and (n+1)/2 nodes respectively. Also when a node has less than n/2 entries it either steals some entries from its neighbours or is merged with one of its neighbours. When keys are inserted into a B-Tree in order you end up with all nodes half full, the worst case scenario.
I've read about another variant where a full node shoves entries into its neighbours to make space or 2 full nodes are split into 3 nodes with 2n/3 entries. The same way a node with less than 2n/3 entries steals some entries from its neighbours or 3 nodes are merged into 2. This garanties a higher utilization.
In both cases though I can see an access pattern of alternating insert/remove where each operation causes an expensive split or merge.
So my questions are:
Mrvn
in a traditional B-Tree a node is split when it has n+1 entries (when it is over full) producing 2 nodes with n/2 and (n+1)/2 nodes respectively. Also when a node has less than n/2 entries it either steals some entries from its neighbours or is merged with one of its neighbours. When keys are inserted into a B-Tree in order you end up with all nodes half full, the worst case scenario.
I've read about another variant where a full node shoves entries into its neighbours to make space or 2 full nodes are split into 3 nodes with 2n/3 entries. The same way a node with less than 2n/3 entries steals some entries from its neighbours or 3 nodes are merged into 2. This garanties a higher utilization.
In both cases though I can see an access pattern of alternating insert/remove where each operation causes an expensive split or merge.
So my questions are:
- What other split/merge rules do you know?
- What do you recommend and why?
Mrvn