Search trees and ordered indexes
An ordered index is a data structure that keeps keys sorted, so a program can find a key, the next key, or every key in a range. In memory, the main candidates are balanced binary search trees, B-trees, skip lists, sorted arrays, radix trees and learned indexes; on disk, B+-trees and log-structured merge trees. For small entries, B-trees that pack many keys into each node usually beat node-based binary trees. Data that never changes is searched fastest in a sorted array laid out for the cache, or in a tree tuned for it.
Three questions are disputed: whether radix trees beat B-trees, which depends on the key type; whether learned indexes beat tuned B-trees outside favourable workloads; and which storage index wins. On storage, device and benchmark length change the ranking.
Hash tables, which find exact keys but keep no order, have their own article, and so does the choice between families of structures, in Choosing algorithms and data structures.
Binary trees, B-trees and skip lists in memory
B-trees against binary trees
A balanced binary search tree, such as a red-black or AVL tree, stores one key per node and follows a pointer at each step. A B-tree stores several keys per node, so a search visits fewer nodes.
In-memory B-trees can beat the C++ standard library’s std::set on speed and memory. In one set of insertion and access benchmarks, almost every tree implementation tested outperformed std::set in almost every task (Barratt & Zhang, 2019). Abseil reports that 64-bit libstdc++ std::set<int32_t> allocates 40 bytes per stored value, against 4.3–5.1 bytes for its btree_set<int32_t> (Abseil, n.d.b).
Node size is a tuning choice that depends on the machine. Of the orders one study tried, order 16 (up to 16 children per node) was fastest on its test machine (Barratt & Zhang, 2019). In another, a linear scan inside a node was faster than binary search up to 64 children, and binary search was faster above that (Dinklage et al., 2021).
Binary trees can close most of the gap on lookups if their nodes are placed in memory with the cache in mind, but updates then cost more. Relocating AVL and red-black nodes made their random search close to a B+-tree with cache-block-sized nodes, and the layout improved binary-tree search time by 50–55%. A local variant of the layout increased random insertion time by about 20–70% (Saikkonen & Soisalon-Soininen, 2008).
When B-trees lose
B-trees are not always faster, and they give weaker guarantees about entries staying in place. Insertion and deletion in Abseil’s B-trees can invalidate pointers and iterators to other elements. Abseil names std::array<int32_t, 16> as a value type for which the standard sorted containers outperform its B-trees (Abseil, n.d.b).
Cache-conscious variants of the B+-tree can lose on updates what they gain on searches. In Rao and Ross’s benchmark, a node split in their cache-sensitive B+-tree copied a whole group of sibling nodes, so the conventional B+-tree inserted faster. The cache-sensitive tree only pulled ahead when more than 45% of operations were searches; a fully preallocated variant was fastest across the mixes tested but used more space (Rao & Ross, 2000).
For integer keys, structures built on the bits of the key can beat B-trees. One study tested predecessor search (find the largest key not above a query) over 2^30 64-bit keys. There, B-trees had 14–56% lower average throughput than y-fast tries, a structure specialised for integer keys (Dinklage et al., 2021).
Skip lists
A skip list is a sorted linked list with extra levels of shortcut pointers chosen at random. The evidence on how it compares with trees is thin and mostly old or from its designers. In Pugh’s original 1990 comparison with integer keys, the skip list searched slightly slower than a nonrecursive AVL tree (0.051 against 0.046 ms). It inserted and deleted faster. Those insertion and deletion figures excluded memory-management costs (Pugh, 1990).
Later results point both ways. In a small student study of six ordered dictionaries, the skip list had relatively high execution times, especially for random finds (Suban, 2023). The authors of PI, a batched parallel skip list, report up to about three times the query throughput of Masstree, another in-memory index, in their own experiments (Xie et al., 2016). Other designers compared their index against skip-list and tree baselines that were not thread-safe, so their results concern read-only or single-writer use (Wu et al., 2019). Concurrent designs are covered in Concurrent data structures.
Static data: sorted arrays and their layouts Strong evidence: many studies agree on this
When the keys do not change, a sorted array searched by binary search needs no index space at all, but plain binary search is slow on large arrays. In Rao and Ross’s static study, it took three times as long as a cache-sensitive search tree and seven times as long as hashing. Their cache-sensitive search trees beat T-trees and B+-trees on both lookup speed and index space (Rao & Ross, 1999).
The best layout of a sorted array depends on its size. Khuong and Morin found sorted arrays with tuned binary search fastest at small sizes. At large sizes the Eytzinger order was usually fastest; it stores an implicit search tree in the array in breadth-first order (Khuong & Morin, 2017).
The Eytzinger advantage has been reproduced on other hardware. On one Intel laptop at 1 GB of uniform integers, binary search took about 1,150 ns per query against 200 ns for the Eytzinger layout (Groot Koerkamp, 2024). These figures measure throughput over many independent searches, not the latency of one search that waits for the previous one (Groot Koerkamp, 2024). Apple showed the Eytzinger layout running twice as fast as a branchless binary search on its own processors (Apple, 2025).
Newer tree layouts that use SIMD instructions (one instruction comparing several keys at once) beat the older cache-sensitive designs. In a 2025 comparison on a Xeon server, two new SIMD B-trees outperformed every traditional index tested on point queries, including an implementation of Rao and Ross’s tree (Bellomo et al., 2025). GPUs help only for large trees. The FAST tree searched twice as fast on a CPU as on a GPU when the tree fit in cache, and 1.7 times slower at large sizes (Kim et al., 2010).
Tries and radix trees
A trie, or radix tree, finds a key by following its bytes or bits one piece at a time instead of comparing whole keys. Whether the adaptive radix tree (ART), a radix tree designed for in-memory databases, beats a B-tree is contested: it wins on integer keys and loses on strings and scans.
On dense integer keys, ART is about as fast as a hash table while keeping keys in order. In the original benchmark with 16 million keys, a random lookup took 188 processor cycles on dense integers and 352 on sparse ones, against 191 for a chained hash table. It inserted up to 50 million keys per second when they arrived sorted and dense (Leis et al., 2013). An independent study of web-address dictionaries placed ART and another trie in the fastest lookup group, with hash maps. That group was about an order of magnitude ahead of the other structures tested (Mavlyutov et al., 2015).
Against a modern B-tree, the key type decides. In a 2025 comparison, ART beat an adaptive B-tree on point lookups by 129% on sparse integers and 73% on dense ones, but was 34–37% slower on two string datasets. HOT, another trie, came within 5% above to 14% below the B-tree on strings. The B-tree had 85–219% higher scan throughput than the tries and used the least memory (Müller et al., 2025).
Trie benchmarks depend on where the records live. To compare tries as full maps, the 2025 study stored copies of keys and values in separately allocated records that the tries pointed to. Changing record handling, key width and record count together moved HOT’s lookup deficit against ART from 52% to 39% (Müller et al., 2025).
Memory allocation also differs between implementations of the same trie. One Go ART made 1.02 allocations per inserted key, against about 0.07 for a Go B-tree. In another ART library, the ordinary version needed 1.32 allocations per insert and a version using an arena (memory reserved in bulk) needed none (Beck, n.d.; SurrealDB, n.d.).
Hybrid ordered indexes report lookup speed that approaches hashing, but only from their designers. Wormhole, an ordered index, reached 30–92% of a cuckoo hash table’s point-lookup throughput in its authors’ experiments (Wu et al., 2019).
Learned indexes Contested: studies disagree on this
A learned index uses a model of how keys are distributed to predict a record’s position, then searches near the prediction (Kraska et al., 2018). Whether learned indexes beat well-tuned trees is contested. The original proposal reported up to 70% better speed and about ten times less memory than its cache-optimized B-tree baseline (Kraska et al., 2018).
On static, sorted data, a learned index can beat a standard B-tree on speed and size, but not hash tables on speed. The table gives the fastest tested variant of each index on one dataset of the SOSD benchmark (Marcus et al., 2021).
| Index | Lookup time | Index space |
|---|---|---|
| RMI (learned) | 181 ns | 48 MB |
| STX B-tree | 482 ns | 166 MB |
| Interpolating B-tree | 447 ns | 9 MB |
| RobinHash (hash table) | 94 ns | 6,144 MB |
| CuckooMap (hash table) | 115 ns | 1,541 MB |
Building a learned index takes time. On a larger build of the same dataset, the fastest RMI took 80 seconds; PGM and RS, two other learned designs, took 38 and 20 (Marcus et al., 2021).
Independent comparisons find the advantage narrow or reversed. On static integer data, SIMD B-trees led every tested learned index on point-query time across the datasets, with some near ties (Bellomo et al., 2025). Another evaluation favoured learned indexes for read-heavy workloads with smooth key distributions and uniform inserts. They had no advantage with skewed inserts, many range queries, heavy writes, concurrency or string keys (Sun et al., 2023a).
Updatable learned indexes are sensitive to the data they are first built from and to the order of later inserts, and the two effects hit different designs. In one independent test, LIPP was first built from the smallest half of the keys instead of a random half. Its later lookup throughput fell by up to 83.6%, while ALEX changed by at most 21.0%. Insert order hurt ALEX instead. Shuffled rather than sorted inserts gave it 3.1 times the lookup throughput on one dataset, while LIPP moved by at most 2.3% (Luo et al., 2025b).
Rankings between learned indexes can reverse with input order. In a separate ingestion benchmark, LIPP ranged from 4.4 times faster to 1.9 times slower than ALEX, depending on how sorted the input was. It did not complete the fully sorted workload (Raman et al., 2024). The ALEX authors found its throughput fell under every shift of key distribution they tested, but stayed above both B+-trees they compared (Ding et al., 2020).
B+-trees and LSM-trees on storage
On disk, the two main ordered indexes are the B+-tree, which keeps sorted records in pages, and the log-structured merge tree (LSM-tree). An LSM-tree collects writes in memory, writes them out as sorted runs, and later merges runs in the background, a process called compaction. Write amplification is how many bytes the storage device writes for each byte the application writes.
Compaction policy
LSM-trees trade write work against read and space costs through their compaction policy. Leveling merges sorted runs into fewer runs per level and pays a higher write cost. Tiering lets more runs pile up before merging, giving up query speed and space (Luo & Carey, 2018). Bloom filters, compact structures that answer “definitely not here”, let point lookups skip runs that lack the key, but short range queries still read from several levels (Luo & Carey, 2018). Bloom filters are covered in Probabilistic data structures.
Within one engine, the compaction choice changes data movement and tail latency more than scan speed. In a RocksDB-based study, partial leveling moved 34–56% less data while loading than full leveling. Tiering’s tail write latency was about 2.5 times that of full leveling and 5–12 times that of partial compaction, yet it raised average range-scan latency by only about 5% (Sarkar et al., 2021).
Scheduling background compaction work can remove most latency spikes, up to a point. The SILK scheduler cut 99th-percentile latency by up to two orders of magnitude against RocksDB in its tested workloads. Its performance still degraded when peak load was both high and long (Balmau et al., 2019).
Which engine wins
Whether a B+-tree or an LSM-tree performs better depends on the device, the operation and how long the benchmark runs. On an SSD with built-in transparent compression, a modified B+-tree reached 19% higher random-write throughput than RocksDB, an LSM engine, on a 150 GB dataset of 128-byte records (Qiao et al., 2022a). On the same kind of device, the WiredTiger engine led random point reads, at 71,000 transactions per second against 57,000 for RocksDB. RocksDB trailed both page-based trees on 100-record range scans (Qiao et al., 2022b).
Short benchmarks can overstate LSM write throughput. On a freshly trimmed SSD, RocksDB handled 8,000–11,000 updates per second for the first 15 minutes and 3,000 at steady state. The initial state of the SSD also changed both early and steady-state results, especially for WiredTiger (Didona et al., 2021).
Further reading
- Müller, Benson and Leis (2025), “B-Trees Are Back” (Müller et al., 2025): a recent head-to-head of an engineered B-tree against ART and HOT on integers and strings, with care over how records are stored.
- Khuong and Morin (2017), “Array Layouts for Comparison-Based Searching” (Khuong & Morin, 2017): the multi-machine comparison of sorted-array layouts behind the Eytzinger result.
- Marcus et al. (2021), “Benchmarking Learned Indexes” (Marcus et al., 2021): the SOSD benchmark comparing learned indexes, trees and hash tables on static data.
- Sun, Zhou and Li (2023), “Learned Index: A Comprehensive Experimental Evaluation” (Sun et al., 2023a): an independent evaluation that maps where learned indexes help and where they do not.
- Luo and Carey (2018), “LSM-based Storage Techniques: A Survey” (Luo & Carey, 2018): the design space of LSM-trees, including leveling, tiering and Bloom filters.
- Didona et al. (2021), “Toward a Better Understanding and Evaluation of Tree Structures on Flash SSDs” (Didona et al., 2021): how device state and benchmark length change B-tree and LSM-tree results.
First published .
Known gaps
What this article cannot tell you yet.
- Skip lists under concurrent writes lack independent comparisons: the batched parallel skip list and the Wormhole index rest on their authors’ own experiments.
- The ordered maps that language standard libraries ship, and their guarantees, are largely missing; only Abseil’s B-tree containers and the libstdc++ red-black tree appear.
- Concurrent ordered indexes get only brief treatment here.
- How B+-trees and LSM-trees behave on persistent memory, and newer tree designs for SSDs, are missing.
- Storage benchmarks use different devices, compaction policies and durability settings, so no comparison across them holds equivalent settings fixed.
References
- Solid source
- Rated highly trustworthy by the research, and every passage taken from it was found in it.
- Weak source
- Rated low, or a passage taken from it was not found in it.
- Medium trust
- Rated medium by the research.
- Not checked
- Rated high, but its passages could not all be checked against it.
Show all 32 references
- Abseil (n.d.b). B-tree containers. Abseil. https://abseil.io/about/design/btree Weak source Documentation, read in full.
- Apple (2025). Optimize CPU performance with Instruments. Apple Developer, WWDC25. https://developer.apple.com/videos/play/wwdc2025/308/ Solid source Documentation, read in large part.
- Balmau, O., Dinu, F., Zwaenepoel, W., Gupta, K., Chandhiramoorthi, R., & Didona, D. (2019). SILK: preventing latency spikes in log-structured merge key-value stores. 2019 USENIX Annual Technical Conference. https://www.usenix.org/system/files/atc19-balmau.pdf Medium trust Peer-reviewed, read in large part.
- Barratt, J., & Zhang, B. (2019). Cache-friendly search trees; or, in which everything beats std::set. arXiv. https://arxiv.org/abs/1907.01631 Medium trust Preprint, read in large part.
- Beck, K. (n.d.). AdaptiveRadixTree2. GitHub. https://github.com/KentBeck/AdaptiveRadixTree2 Medium trust Documentation, read in large part.
- Bellomo, L., Cianci, G., de Rosa, L., Ferragina, P., & Odorisio, M. (2025). A comparative study of compressed, learned, and traditional indexing methods for integer data. 23rd International Symposium on Experimental Algorithms (SEA 2025). https://drops.dagstuhl.de/storage/00lipics/lipics-vol338-sea2025/html/LIPIcs.SEA.2025.5/LIPIcs.SEA.2025.5.html Solid source Peer-reviewed, read in full.
- Didona, D., Ioannou, N., Stoica, R., & Kourtis, K. (2021). Toward a better understanding and evaluation of tree structures on flash SSDs. Proceedings of the VLDB Endowment. https://kkourt.io/papers/p364-didona.pdf Solid source Peer-reviewed, read in large part.
- Ding, J., Minhas, U. F., Yu, J., Wang, C., Do, J., Li, Y., et al. (2020). ALEX: an updatable adaptive learned index. Microsoft Research. https://www.microsoft.com/en-us/research/wp-content/uploads/2020/04/MSRAlexTechnicalReport.pdf Solid source Read in large part.
- Dinklage, P., Fischer, J., & Herlez, A. (2021). Engineering predecessor data structures for dynamic integer sets. 19th International Symposium on Experimental Algorithms. https://drops.dagstuhl.de/storage/00lipics/lipics-vol190-sea2021/LIPIcs.SEA.2021.7/LIPIcs.SEA.2021.7.pdf Solid source Peer-reviewed, read in large part.
- Khuong, P., & Morin, P. (2017). Array layouts for comparison-based searching. arXiv. https://arxiv.org/pdf/1509.05053 Medium trust Peer-reviewed, abstract only.
- Kim, C., Chhugani, J., Satish, N., Sedlar, E., Nguyen, A. D., Kaldewey, T., et al. (2010). FAST: fast architecture sensitive tree search on modern CPUs and GPUs. Proceedings of the 2010 ACM SIGMOD International Conference on Management of Data. https://www.researchgate.net/publication/221213860_FAST_fast_architecture_sensitive_tree_search_on_modern_CPUs_and_GPUs Solid source Peer-reviewed, read in large part.
- Groot Koerkamp, R. (2024). Static search trees: 40x faster than binary search. CuriousCoding. https://curiouscoding.nl/posts/static-search-tree/ Solid source Blog post, read in large part.
- Kraska, T., Beutel, A., Chi, E. H., Dean, J., & Polyzotis, N. (2018). The case for learned index structures. Proceedings of the 2018 International Conference on Management of Data. https://arxiv.org/pdf/1712.01208 Medium trust Peer-reviewed, read in large part.
- Leis, V., Kemper, A., & Neumann, T. (2013). The adaptive radix tree: ARTful indexing for main-memory databases. 2013 IEEE 29th International Conference on Data Engineering (ICDE). https://www.db.in.tum.de/~leis/papers/ART.pdf Not checked Peer-reviewed, read in large part.
- Luo, C., & Carey, M. J. (2018). LSM-based storage techniques: a survey. arXiv. https://arxiv.org/html/1812.07527 Medium trust Peer-reviewed, read in large part.
- Luo, Y., Xie, M., Tong, Y., Jiang, S., & Chai, Y. (2025b). Understanding robustness issues of updatable learned indexes. Proceedings of the ACM on Management of Data. https://minhui-xie.github.io/papers/sigmod26-robust_learned_index.pdf Solid source Peer-reviewed, read in large part.
- Marcus, R., Kipf, A., van Renen, A., Stoian, M., Misra, S., Kemper, A., et al. (2021). Benchmarking learned indexes. Proceedings of the VLDB Endowment. https://rmarcus.info/blog/courses/cis6500/06b_benchmark.pdf Solid source Peer-reviewed, read in large part.
- Mavlyutov, R., Wylot, M., & Cudré-Mauroux, P. (2015). A comparison of data structures to manage URIs on the web of data. European Semantic Web Conference, Springer. https://exascale.info/assets/pdf/uriencoding.pdf Solid source Book, read in large part.
- Müller, M., Benson, L., & Leis, V. (2025). B-trees are back: engineering fast and pageable node layouts. Proceedings of the ACM on Management of Data. https://www.cs.cit.tum.de/fileadmin/w00cfj/dis/papers/btrees-are-back.pdf Solid source Peer-reviewed, read in large part.
- Pugh, W. (1990). Skip lists: a probabilistic alternative to balanced trees. Communications of the ACM. https://g-trees.github.io/g_trees/assets/references/pugh1990skip.pdf Medium trust Peer-reviewed, read in large part.
- Qiao, Y., Chen, X., Zheng, N., Li, J., Liu, Y., & Zhang, T. (2022a). Closing the B+-tree vs. LSM-tree write amplification gap on modern storage hardware with built-in transparent compression. 20th USENIX Conference on File and Storage Technologies. https://www.usenix.net/system/files/fast22-qiao.pdf Solid source Peer-reviewed, read in large part.
- Qiao, Y., Chen, X., Zheng, N., Li, J., Liu, Y., & Zhang, T. (2022b). Revisiting B+-tree vs. LSM-tree: the arrival of modern storage hardware with built-in transparent compression changes the battlefield. ;login: Online. https://www.usenix.org/publications/loginonline/revisit-b-tree-vs-lsm-tree-upon-arrival-modern-storage-hardware-built Medium trust Read in large part.
- Raman, A., Huynh, A., Lu, J., & Athanassoulis, M. (2024). Benchmarking learned and LSM indexes for data sortedness. International Workshop on Testing Database Systems. https://cs-people.bu.edu/mathan/publications/dbtest24-raman.pdf Solid source Peer-reviewed, read in large part.
- Rao, J., & Ross, K. A. (1999). Cache conscious indexing for decision-support in main memory. Proceedings of the 25th VLDB Conference. https://www.vldb.org/conf/1999/P7.pdf Solid source Peer-reviewed, read in large part.
- Rao, J., & Ross, K. A. (2000). Making B+-trees cache conscious in main memory. Proceedings of the 2000 ACM SIGMOD International Conference on Management of Data. https://cadmo.ethz.ch/education/lectures/FS17/SDBS/RaoRoss-sigmod00.pdf Solid source Peer-reviewed, read in large part.
- Saikkonen, R., & Soisalon-Soininen, E. (2008). Cache-sensitive memory layout for binary trees. Fifth IFIP International Conference on Theoretical Computer Science. https://dl.ifip.org/db/conf/ifipTCS/ifipTCS2008/SaikkonenS08.pdf Solid source Book, read in large part.
- Sarkar, S., Staratzis, D., Zhu, Z., & Athanassoulis, M. (2021). Constructing and analyzing the LSM compaction design space. Proceedings of the VLDB Endowment. https://www.vldb.org/pvldb/vol14/p2216-sarkar.pdf Solid source Peer-reviewed, read in large part.
- Suban, J. (2023). Empirical evaluation of time complexity of ordered dictionaries with ALGator. Proceedings of the 9th Student Computing Research Symposium. https://www.scores.si/assets/pdf/scores2023.pdf Solid source Peer-reviewed, read in large part.
- Sun, Z., Zhou, X., & Li, G. (2023a). Learned index: a comprehensive experimental evaluation. Proceedings of the VLDB Endowment. https://www.vldb.org/pvldb/vol16/p1992-li.pdf Medium trust Peer-reviewed, read in large part.
- SurrealDB (n.d.). artmap. GitHub. https://github.com/surrealdb/artmap Medium trust Documentation, read in large part.
- Wu, X., Ni, F., & Jiang, S. (2019). Wormhole: a fast ordered index for in-memory data management. Fourteenth EuroSys Conference 2019. https://ranger.uta.edu/~sjiang/pubs/papers/wu19-wormhole.pdf Solid source Peer-reviewed, read in large part.
- Xie, Z., Cai, Q., Jagadish, H. V., Ooi, B. C., & Wong, W. (2016). PI: a parallel in-memory skip list based index. arXiv. https://arxiv.org/abs/1601.00159 Medium trust Preprint, read in large part.