Menu

1 / 2

Storage Engines Explained: B-Tree vs LSM Tree

DEV Community: cassandra·Dilip V P·14 days ago
#FUUEVjdJ
#devtocassandra#devto#dev#order#mysql
Long article (1337 words) — no AI summary yet.
Reading 0:00
15s threshold

MySQL reads fast. Cassandra writes fast. It all comes down to where each one puts your row the moment you write it. MySQL keeps it in a B-tree, Cassandra in an LSM tree, and this article follows one order through both.

The video tells the same story in six minutes. This is the written version, with the SQL.

One order, one row, one page

Say Anna orders a pizza. That tap becomes one row in the orders table:

CREATE TABLE orders ( order_id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT , customer VARCHAR ( 64 ) NOT NULL , item VARCHAR ( 64 ) NOT NULL , status VARCHAR ( 16 ) NOT NULL , PRIMARY KEY ( order_id ) ) ENGINE = InnoDB ;

INSERT INTO orders ( customer , item , status ) VALUES ( 'Anna' , 'pizza' , 'placed' ) ;

Enter fullscreen mode

Exit fullscreen mode

MySQL doesn't store that table as a list of rows. It stores it in pages, blocks of 16 KB, and one page holds a few hundred small rows like this one.…

Continue reading — create a free account

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