Skip to content
About
Main content
Bytes at Rest

Storage: Physical Organization

What should sit next to what, given that I must decide at write time and find out at read time?

Who this mechanism is for: a developer who writes code, calls APIs and knows basic SQL, but has never studied how a database or a data lake lays its bytes out on disk. You do not need any database knowledge. Every technical term is explained the first time it appears, and again in the glossary at the end. If you know what a file and a table are, you can read this mechanism.

The story we will follow

Kavya is a data engineer at Parcelo, a parcel-delivery company. Every time a depot scans a parcel, one row is added to a table called scan_events. The table now has about 2 billion rows, 25 and roughly 200 bytes per row, so about 400 GB in total. It lives in cloud (a service such as Amazon S3 that stores files and charges per request). Her colleague Dev runs the operational PostgreSQL database that the tracking website and the depot apps use.

Two screens matter to the business. The tracking page: a customer types one parcel number and sees every field of that parcel's scans. And the weekly weight report: the average parcel weight per depot per week, which reads only two columns of the table, but for every row.

In this mechanism Kavya meets five problems, one at the start of each article. Each problem looks like a bug: a slow lookup, a huge nightly job, a query that suddenly scans everything. Each one is actually a consequence of how bytes are placed next to each other. At the end of each article we go back and solve her problem with the mechanisms that part explained. All numbers in the story are illustrations.

The main idea of this whole mechanism:

How this mechanism is organized

After that: a summary, hands-on labs, interview questions and a glossary.

One request: do not skip the formulas with numbers. Each article has one or two small formulas. The worked examples show that they are simple arithmetic, and that the results are very large or very small. The size of the result is the lesson.

What do I do, and what does each option cost?

Can I see it myself?

Can I reason about it under questioning?

Trade-offs

The tensions this mechanism takes a position on. Each recurs across mechanisms.

Show all 10 trade-offs
Recurring principles

Ideas this mechanism meets that keep coming back, mechanism after mechanism.

Show all 6 principles