Choose a layout from a real filter
A year of dispatches occupies 36.5 TB, roughly 100 GB per day.
The interview prompt
A year of dispatches occupies 36.5 TB, roughly 100 GB per day. Most finance queries read seven days, and one seller demands a one-order lookup. Sketch the partition and clustering strategy, then show what it cannot guarantee.
Estimate the bytes that could be skipped
With an even day distribution, a seven-day request touches roughly 700 GB before column pruning and compression effects. Date pruning could eliminate the other 35.8 TB from a full-year scan. That assumes the engine recognizes the predicate and the physical files line up with the filters. Inspect the number of files opened and actual bytes read.
Partitioning also by 10,000 sellers creates up to 10,000 seller-day groups a day. At 100 GB per day, an even distribution averages only about 10 MB per group. Real sellers are uneven, leaving many tiny groups and a handful of large ones. Clustering within a coarser date layout may offer useful filtering without that file count. A one-order support lookup may justify a separate keyed access path.
Keep a late-correction case on the board. A dispatch received today with last month’s event date belongs to an older business range. Determine how it is merged, which snapshots readers can see during the update, and when old files are retired. A partitioning argument is incomplete until someone can explain how the data is written and maintained.
The model behind the answer
The buyer reads the last four weeks of dispatches. Partitioning files by dispatch date lets the engine skip older data. Within the selected dates, clustering or sorting by a commonly filtered field can reduce reads further, depending on the engine and file statistics. Measure files opened and bytes scanned as well as elapsed time. A warm cache can flatter a poor layout.
There is a cost to finer partitions. A partition per seller per hour can create thousands of tiny files, with more time spent planning and opening them than reading data. Choose a coarser boundary, compact small files, and test filtered scans again. A correction received today for a dispatch last month must still find the right logical row.
Apache Iceberg illustrates the separation between logical grain and physical layout. A table can evolve its partition specification and retain the metadata required to read files written under earlier specifications. Newly written data can use the new layout while older files keep theirs. Apache Iceberg on partition evolution
Review an agent’s physical design experiment
Give the agent one week of representative query predicates and ask for a repeatable comparison of two layouts. Include an order lookup and a correction to last month. Record the logical answer, files opened, actual bytes read and bytes rewritten.
Reviewer decision. Seven evenly sized days represent about 700 GB of logical input in the example. Treat that as a sizing assumption. If a proposed layout opens thousands of tiny files or shifts cost onto corrections, show the measured trade-off before selecting it. SQLite examples elsewhere in the guide cannot establish this warehouse result.
Further reading. Designing Data-Intensive Applications, 2nd ed., on partitioning, clustering and range access in warehouses.
One more question
Last month the table switched from month to day partitions. Do earlier queries automatically enjoy day-sized files for all history?
Check your reasoning
An evolving table format can support both layouts. Older files keep their physical organization until rewritten. Benchmark recent and historical ranges independently, then compare the savings from a rewrite with its compute and operational cost.
Previous · One order lookup and a year of shipments · Next · When one school district becomes half the traffic · Complete series map