Many (perhaps most?) database applications today use B-Trees and variations to store data, because this data structure optimizes the read, write and seek operations on a hard disk (and these operations in turn play an important role in the overall efficiency of the databases).

Should Solid State Drives (SSDs) completely outplace traditional hard disks (HDDs), though, could we say that B-Trees and variations will become obsolete, giving room for data structures that are more efficient operating on direct access memory? If so, what will those structures be? (e.g., hash tables, AVL trees)

  • Are you asking if they will become obsolete from a database implementation standpoint or in general because the have a lot of other applications outside of database applications. – Pemdas Oct 18 '11 at 15:50
  • From a database point of view. – Daniel Scocco Oct 18 '11 at 16:52

B-Trees are most often used for database indexes on hard disk, but they have advantages even as an in-memory data structure, given the modern memory heirarchy with multiple layers of cache and with virtual memory. Even if virtual memory is on an SSD, that won't change.

I use an in-memory B+-style multiway tree library that I wrote quite a lot in C++. It can have performance advantages - the reason it was originally written was to try to use cache better - but I have to admit it often doesn't work that way. The problem is the trade-off which means items have to move around within nodes on inserts and deletes, which doesn't happen for binary trees. Also, some of the low-level coding hacks I used to optimise it - well, they probably confuse and defeat the optimiser, truth told.

Anyway, even if your databases are stored on an SSD, that's still a block-oriented storage device, and there's still an advantage to using B-Trees and other multiway trees.

BUT about ten years ago, cache-oblivious algorithms and data structures were invented. These are oblivious to the size and structure of caches etc - they make (asymptotically) the best possible use of any memory heirarchy. B-Trees need to be "tuned" to a particular memory heirarchy to make the best use (though they work fairly well for quite a wide range of variation).

Cache oblivious data structures aren't often seen in the wild yet, if at all, but it time they may well make the usual in-memory binary trees obsolete. And they may also prove worthwhile for hard disks and SSDs as well, since they don't care what the cluster-size or hard-disk cache page size is.

Van Emde Boas layout is very important in cache-oblivious data structures.

The MIT OpenCourseware algorithms course includes some coverage of cache oblivious data structures.

  • 1
    Interesting. You gave some good pointers (no pun intended!) to explore this topic further. Thanks. – Daniel Scocco Oct 18 '11 at 15:34
  • This MIT course also has information on cache oblivious data structures. – dan_waterworth Jun 15 '13 at 16:47
  • Hi, did you mean that B-tree will obsolete, because of cache-oblivious data structures, not because of SSDs? But how about other data structures, like block management in a DBMS? – Yang Bo Apr 4 '14 at 3:56
  • @user955091 - I meant because of cache-oblivious data structures (pedantically meaning structures that are optimal in the cache-oblivious model), but I was a bit overexcited about them back then. Other data structures aren't going to disappear any time soon. For one thing, cache isn't the only performance issue - parallelism makes different demands. Besides, needing key-based ordering is often a special case - normally, hash tables are king. It can be hard to see a "randomized" layout as cache-friendly, but one access to directly fetch the item is hard to beat - you don't need locality. – Steve314 Apr 4 '14 at 7:52

A priori, yes, most database engines will have to be rewritten since the B-Tree will no longer be the most efficient data structure to store data, given that locality is all important in a hard drive where the disk moves slowly and data is fetched in blocks, meaning that any change to the data needs to:

  1. Move the head to the right location on disk (~10ms).
  2. Wait for the disk to rotate (at 10k rpm, that means 167 rotations per second, but on average we only wait for half a rotation, so ~3ms).
  3. Read the block (~3ms).
  4. Modify in RAM. (~10ns)
  5. Move the head to the right location on disk again (~10ms again).
  6. Wait for the disk to rotate again (~3ms again).
  7. Write the block (~3ms).

That's 10+3+3+10+3+3 = 34 ms

On average, doing the same on an SSD is only 1ms, regardless of the position on the disk.

And since a hashtable is far faster, we could think a hashtable would be a better replacement.

The only problem is that hashtables are not order preserving and therefore it is not possible to find next and previous like Van Emde Boas does.


  1. http://en.wikipedia.org/wiki/Van_Emde_Boas_tree
  2. http://bryanpendleton.blogspot.com/2009/06/cache-oblivious-data-structures.html

Why find next and previous is important? Imagine getting all elements larger than x and smaller than z, you need to use indexes with find previous and find next.

Well, the only problem is that we haven't found hashtables with order preserving abilities. Maybe the size of the bucket in the B-tree will be important but that gets resolved with cache oblivious algorithms.

So I would say this is an open ended problem.

  • A hash table is (normally) cache oblivious WRT modelling its performance, but that doesn't mean it's efficient in that model. The problem is that hash functions are normally designed to scatter items "randomly" - that's why hash tables are unordered and also why they have poor locality. That means even if you can identify a sequence of items with adjacent keys, you're unlikely to benefit from reading two or more items per block (SSDs are still block devices). – Steve314 Apr 16 '13 at 21:28
  • 1
    Of course hashing is also sometimes called "key transformation" and the transform doesn't have to be "random" - maybe it's possible to define a hash function that allows for reasonably efficient sequential access (not eliminating the searching - information is lost by the hash function, after all - but minimising it) and gives some locality benefits while still keeping hash collisions rare. – Steve314 Apr 16 '13 at 21:31

protected by gnat May 15 '18 at 20:56

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.