B+ Tree Database Index
Interactive B+ Tree with node splits, key promotion, and leaf linked-list range scans.
About this tool
A B+ tree is the index structure behind almost every relational database and many file systems. Each node holds many keys, so the tree is wide and very shallow: a few levels can index millions of rows, and each level costs one disk or page read. All records live in the leaves, which are linked left to right so range queries can scan them without climbing back up.
This lab implements a real B+ tree of configurable order. It animates the descent for inserts and lookups, splits overflowing leaves (copying the separator key up) and internal nodes (moving it up), grows a new root when needed, and shows a range scan walking the leaf chain.
How to use B+ Tree Database Index
- Choose the order — the maximum number of children per node. Small orders split often, which is easier to watch.
- Insert keys one by one, or click “Insert 9 more keys” to grow the tree quickly.
- Search a key to see one node read per level, then run a range scan to see the leaf-to-leaf pointer walk.
- Watch the counters: no matter how many keys you add, every leaf stays at the same depth.
Examples
Leaf split (order 3)
Leaf [10, 20] receives 30
Split into [10, 20] and [30]; 30 is copied up as a separator, so the new root is [30]
Range scan
Range [15, 42]
Descend once to the leaf containing 15, then follow next-leaf pointers until a key exceeds 42
B+ tree vs. B-tree
- In a B+ tree internal nodes only hold separator keys; all values live in the leaves. In a B-tree values can sit in any node.
- Smaller internal nodes mean higher fan-out and fewer levels.
- Linked leaves make full scans and range queries sequential reads.
How shallow is it?
With 16 KB pages and 8-byte keys plus pointers, an InnoDB internal page holds roughly 1,000 children. Three levels then reach about a billion entries, which is why primary-key lookups in MySQL usually need only three or four page reads — and the top levels are almost always cached in memory.
Frequently asked questions
Everything you need to know about this tool and data security.
Why is the key copied up on a leaf split but moved on an internal split?
Leaves must keep every key because they hold the data. Internal nodes only guide the search, so the middle separator can leave the node and move to its parent.
What happens on delete?
An underfull node borrows a key from a sibling or merges with it, which can shrink the tree from the root. This lab focuses on insert, search and range scans.
Why do databases prefer sequential primary keys?
Increasing keys always go into the rightmost leaf, so pages fill completely and splits are cheap. Random keys (like UUIDv4) split pages all over the tree and leave them half empty.
Is my data safe when using this tool?
Yes, 100% safe. This tool operates entirely inside your web browser using client-side JavaScript and WebAssembly. Your data never touches any external server.
Related Tools
Interactive BST visualizer with insertion, deletion, and tree traversals.
Self-balancing binary search tree with LL, RR, LR, and RL rotation animations.
Interactive Max/Min Heap with array vs tree dual view and sift animations.
Featured Projects tech-fun.net
Explore more AI & productivity tools
Nihongo GameBox
Master Japanese typing, Kana, and JLPT N5–N1 vocabulary through interactive retro arcade games.
ResumeGPT
Tailors CVs and cover letters to every job opportunity with a multi-agent LLM pipeline, job tracking, and scheduled discovery.
CollectMind
Turns your bookmarks into a searchable AI knowledge base — entirely on-device, powered by Chrome's built-in Gemini Nano.