Execution deals in chunks; storage answers a different question: where those chunks live, at what granularity, and how updates and versions fit in.
Part four of the plan series: the four-layer in-memory layout.
1. Four layers
table
└── row group (122,880 rows)
└── column data (one column)
└── column segment (256 KB block, up to 60 vectors)
└── vector (2,048 rows)
The numbers are aligned on purpose:
60 × 2,048 = 122,880— one row group is exactly 60 full vectors;- a segment holds up to 60 vectors, about 256 KB;
- a vector is the smallest read/write unit and the executor’s batch size.
Alignment pays off: scans skip whole segments and read whole vectors, with no cross-block stitching.
2. Why slice by column
Inside a row group, data is sliced by column, then by segment. That gives:
- reading only needed columns (column pruning pays off directly);
- per-column encoding/compression (possible later);
- updates touching one column instead of rewriting a row.
3. Where version data lives
MVCC needs multiple versions of the same row. plan records row and column versions separately:
| Level | Structure | Granularity |
|---|---|---|
| row versions | version node (one per row group) | chunk info, one per 2,048 rows |
| column versions | update node (one per column data) | update info list, one per 2,048 rows |
Why per column? Because different transactions can update different columns. With row versions only, “transaction A changed column 1, transaction B changed column 2” can’t be expressed.
Each transaction has its own update info; multiple transactions chain into a list, and readers walk it to find their visible version.
4. Statistics in three layers too
| Level | Records |
|---|---|
| table | stats per column |
| column data | nulls, distinct count, min/max for the column |
| column segment | the same for each segment |
Statistics make “skip the whole segment” possible: min/max rules out blocks that can’t match.
5. A corollary
For a two-column query with a range predicate, the ideal path is:
- skip segments using min/max;
- read vectors for those two columns only;
- apply selection on vectors.
If any step fails, performance drops by an order of magnitude — which is why “did column pruning work?” deserves its own check.
6. Checklist
| Check | Expectation |
|---|---|
| Is a row group 122,880 rows? | yes |
| Are segments skipped? | when min/max rules them out |
| Do updates touch only the affected column? | yes (column-level update node) |
| Are stats present at all three levels? | yes |
7. Next
With layout settled, concurrency must be correct: transactions, timestamps and GC.
Series: Database kernel · Project page
Get the next post
New posts on database kernels and engineering.