Day 310 — Schema design when every table has a time on it
Saturday, 12 June 2027 · Week 45 of 52 · Production · Study day · 60 min
Your store grew by accretion and the queries you now run are not the ones it was designed for, which is normal and worth one day of correction before phase 11 depends on it.
What you should be able to do tonight
- State the three schema decisions that matter for a time series store and justify yours.
- Report the query time improvement from the change you make.
Tasks 60 min
30 min Audit your own schema against three questions: is the sort order aligned with the most common query predicate, are the types as narrow as they can be, and is anything stored that could be derived. Then make the single highest-value change and measure the query time before and after.
30 min Handle the two-timestamp design properly: your tables carry an observation time and an availability time, and the as-of query filters on both. Check whether the physical layout supports that filter efficiently or whether every as-of query scans the whole table. Fix it if not.
Resources
- DuckDB documentation tool
- PostgreSQL tutorial (official) course
Deliverable
A schema audit against three questions, one change made, and the query time improvement measured.
Checkpoint
What sort order does your bar table use, and why is it the right one for the query you run most?
Prepare for tomorrow
Ten minutes tonight so Day 311, Sunday, 13 June 2027 starts clean. This is what the evening email sends you.
Write your daily bars to Parquet partitioned by year, and again unpartitioned.
Run a query for a single year against both and time it.
Note the file sizes as well as the times.