Full lesson
Explore the full explanation, examples, and visuals at your own pace.
Part 1
General knowledgeIn ObsessionDB, S3 holds the only durable copy of your rows, and caches make reads fast. S3 is object storage, and the NVMe cache is a fast disk layer in front of it. We'll follow one events table, from a batch insert to two different queries.
Data lives in S3 plus cache; metadata lives in Chemist.
ObsessionDB splits two jobs. The rows themselves live in S3 and the cache. The metadata, the bookkeeping that orchestrates inserts and merges, belongs to Chemist, the coordination layer.
Step 1: batch INSERT into events
Say a batch INSERT into the events table runs on the writing node. It already holds the new part's bytes, so it sends them to S3 and populates its own NVMe cache at the same time. Once S3 confirms the durable copy is stored, the node commits the metadata to Chemist. Only then is the part visible and queryable.
Step 2: other nodes get ready
Once the metadata commit lands, the new events part becomes visible. Other nodes get a change notice. They then prewarm their mark and primary-index caches, reading from the now-warm NVMe cache. They don't fetch the events rows themselves. Those only get read later, if a query actually asks for them.
Why Tier 4 RAM caches matter
Marks are index entries that point to data ranges, and the primary index holds sample keys for pruning. Without the mark cache, every column read costs an extra S3 GET. The writing node has both warm for free, since marks stay in memory.
- Mark cache maps marks to data ranges
- No marks: extra S3 GET per column
- Writing node gets both warm free
Every read walks down until a hit
A SELECT starts in RAM. The marks and primary index let the query prune granules, so it only reads the column data it needs. Then it looks on the owner node's NVMe. On a miss, it asks a peer node over the network. Only if that misses too does it fall back to S3.
Dashboard: yesterday's events (warm)
Now the dashboard asks for yesterday's events. The query node first gets marks and the primary index from the RAM caches, and that prunes the granules it needs. Then it reads the columns from the owner NVMe, and it's a cache hit, because the part was cached when it was written. The results go straight back, and S3 is never touched.
Agent: last year's events (cold)
Now the agent asks for last year's events. The query node reads columns from the NVMe cache, and it's a miss, on the owner and on the peer. So it goes down to S3 with a GET for the column data. S3 returns it, the query node sends results back to the agent, and it also populates the cache.
Second run: stops at the NVMe cache
Run the agent's query a second time, and the walk is shorter. The SELECT still prunes granules using the marks and primary index in RAM. Then it reads columns from the owner NVMe, and this time it finds them. The peer and S3 are never checked. Reads stop at the first hit.
Writes fill S3 and cache together; reads stop at the first hit.
Writes fill S3 and cache together; reads stop at the first hit. So expect a cold historical query to pay S3 latency once, assuming the data stays cached.