Storage engines
0-day streakReview

Your progress

Level 1

0 XP100 XP to level 2
0day streak
0best streak
0topics started
0cards reviewed
    Review cards

    Progress is stored only in this browser. No account is required.

    Layer 3 · Go deeper · 9 min

    Go deeper

    Size it, build it, then make the calls an interviewer will push you on.

    Back of the envelope

    Size it up

    Tap through each step of the arithmetic.

    One 100-byte change to a cold PostgreSQL page. How many bytes get written?

      What does leveled compaction cost a 500 GB RocksDB database?

        How hard does a PostgreSQL checkpoint hit the disk?

          Build-up · 6 steps

          Follow one commit through a B-tree

          PostgreSQL and InnoDB never write a changed page home at commit. They follow the write-ahead rule: log first, data later.

          Step 1 of 6

          Change the page in memory

          The page is read into the buffer pool if needed, changed there and marked dirty. In PostgreSQL, MVCC makes the change a new row version, not an overwrite.

          4 interview moments

          You’re the candidate

          The interviewer pushes on the hard parts. Pick an approach and see how it holds up.

          1. Deep dive 1 of 4

            Interviewer

            “Orders already live in PostgreSQL. Now you need a write-heavy event store, read mostly by key. Which engine?”

            Your move. Pick an approach:

          2. Deep dive 2 of 4

            Interviewer

            “A Cassandra table is read-heavy, with many updates and deletes. Which compaction strategy do you give it?”

            Your move. Pick an approach:

          3. Deep dive 3 of 4

            Interviewer

            “Click-event inserts wait on an fsync at every commit, and the data can be regenerated. How do you speed them up?”

            Your move. Pick an approach:

          4. Deep dive 4 of 4

            Interviewer

            “Write bursts make PostgreSQL checkpoint every minute instead of every five, and latency spikes. What do you change?”

            Your move. Pick an approach:

          Build-up · 6 steps

          Write, then read, through an LSM

          RocksDB, Cassandra and HBase never modify a file on disk in place. They append to a log and write whole new sorted files.

          Step 1 of 6

          Append to the commit log

          The write first goes to the commit log, which RocksDB calls the WAL, so it survives a crash. It is a sequential append.