Menu

1 / 2

B+Tree vs LSM Tree: Why Your Database's Data Structure Is Everything

DEV Community: cassandra·priteshsurana·8 months ago
#5G6AlpFc
#dev#strong#tree#code#reads
Long article (2883 words) — no AI summary yet.
Reading 0:00
15s threshold

In Post 1 , we looked at a benchmark result where Cassandra wrote 2× faster than PostgreSQL — then read 3× slower before compaction ran. Same hardware. Same data. Wildly different numbers in both directions.

That result is a direct consequence of the data structures each engine is built on. Cassandra and PostgreSQL made opposite choices at the foundation level, and those choices ripple through every read, every write, and every latency number you'll ever measure.

This post explains those choices.

The Problem All Database Indexes Must Solve

Before we look at any specific data structure, let's talk about why this problem is hard.

You want three things from a database index:

Fast writes. When you insert an order, the index should update quickly.

Fast reads. When you query by order_id , finding the right row should take as few disk operations as possible.

Efficient range scans.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.