The page size limit
A Postgres page is eight kilobytes by default, and a single row must fit within one page. Large text, JSON, or bytea values would not fit, so Postgres uses TOAST, which stands for The Oversized Attribute Storage Technique.
How TOAST works
When a row grows too large, Postgres moves big column values out of the main table into a hidden TOAST table linked to it.
- Values may first be compressed in place to try to fit.
- If still too large, they are split into chunks and stored out of line.
- The main row keeps only a small pointer to the TOAST chunks.
Storage strategies
Each column has a storage strategy you can set:
- plain never compresses or moves the value.
- extended allows both compression and out of line storage and is the default for large types.
- external moves out of line but skips compression, which speeds substring reads.
Because TOASTed values live elsewhere, reading a row that does not touch the big column is cheap. Queries that select the large column pay the extra fetch.
Key idea
TOAST keeps rows within the eight kilobyte page limit by compressing large values or moving them into a side table, so wide columns do not slow down queries that ignore them.