Internal data value representation in PostgreSQL.
summary
Explains exactly how SQL literals become in-memory DATUMs and on-page tuples, showing that DATUM is 8-byte on 64-bit systems (changed in 2025) so small types are passed by value and larger ones by reference, how heap_form_tuple, heap_deform_tuple and heap_getattr build tuples, and why pages are limited to 8 KB page with a 2 KB TOAST threshold that triggers compression and out‑of‑line storage; details include varlena headers (1‑byte or 4‑byte), ~1 GB varlena limit, and a 17 MB example compressed to ~94 KB.
AI-written summary · about
chapters (11)
- 0:00Introduction to values in PostgreSQL
- 1:08What is a value in PostgreSQL
- 2:40Data types and fixed-length values
- 4:29Variable-length data types and TOAST
- 6:18Memory representation of values
- 8:49Values on disk and constraints
- 10:56Tuple formatting and alignment
- 13:05TOAST storage technique explained
- 17:25Live demo of value storage sizes
- 22:50Why alignment and padding matter
- 25:04Summary and key takeaways
