What gets TOASTed in Postgres
Postgres TOAST kicks in once a row exceeds 2,032 bytes, compressing variable-length values largest-first and moving them into chunked pg_toast tables (1,996-byte chunks, 18-byte in-row pointers) when compression isn't enough. Column storage strategies (PLAIN, EXTENDED, EXTERNAL, MAIN) control which of those happens, and TOAST differs from large objects in automation, the 1 GB limit, and deletion semantics. Comparing pglz (4 KB window, requires 25% savings) with LZ4 (64 KB window, single-candidate lookup, much faster) shows LZ4 catches more distant repeats and loads faster, while pglz compressed repetitive JSON smaller (19 vs 24 MB) and serves prefix reads like left(body, 200) far faster because Postgres can bound how many chunks it needs. EXTERNAL is the better choice for already-compressed data and for bytea values read from the middle (0.6 ms vs 43 ms LZ4 and 116 ms pglz).
Related posts
- 6 tips to optimize storage costs for your Postgres databases
Neon mediumAdept
Six ways to shrink Postgres storage spend: drop unused indexes (found via pg_stat_user_indexes and pg_index), avoid full database copies for dev and staging by using Neon's copy-on-write branching, choose smaller data types like SMALLINT, order columns largest to smallest to cut alignment padding, shorten Neon's history retention window, and tune autovacuum to limit bloat. Shorter retention saves storage but narrows the point-in-time recovery window. For bloat, look in pg_stat_activity for long-running transactions that block autovacuum.
- OLTP is expensive, you can ClickHouse it.
ClickHouse easyNovice
Data that has stopped changing doesn't need Postgres's ACID machinery, so it can be offloaded to ClickHouse for roughly an order of magnitude better unit economics. Postgres pays for durability, MVCC isolation and synchronous index maintenance on every write: a ~100-byte change touches several 8 KB pages and tens of KB of WAL. It also stores data in uncompressed row pages that thrash the cache once data outgrows RAM. The proposed pattern keeps writes and fresh-row reads in Postgres and replicates settled data to ClickHouse via CDC to serve reads and aggregations, with claimed 10–30× compression and ~100× cheaper aggregations. The cost is slower single-row reads and about a second of eventual consistency. ClickHouse Cloud features (NVMe Postgres, WalShadow CDC, the pg_clickhouse FDW) are pitched as the way to implement it.
- Next steps for Postgres pluggable storage
Supabase easyNovicePostgres 12 introduced a table access method (TAM) API intended to let different tables use different storage engines, but work on ZHeap and the API stalled, leaving gaps: index updates are all-or-nothing, and row versions must be identified by block and offset, which rules out index-organized tables and undo-based versioning. Citus Columnar and EDB's Advanced Storage Pack work within these limits, while OrioleDB has been upstreaming its fork, shrinking its patchset from about 5,000 lines in Postgres 14 to about 2,000 for Postgres 16. If the remaining changes land, possibly in Postgres 17, engines like OrioleDB could ship as ordinary extensions offering undo logs, row-level WAL and index-organized tables.
- Anatomy of a (Postgres) search engine
PlanetScale mediumAdeptInverted indexes power full-text search by mapping each term to a sorted, compressed postings list of document IDs, with optional positional data for phrase/span queries and frequency statistics for BM25 scoring. Postings can be delta-encoded or stored as bitmaps for fast SIMD intersection, and block-level statistics let top-k queries skip whole blocks. Indexes are built as immutable segments plus a mutable segment, with deletes handled by tombstones and periodic merges that trade heavy I/O against per-query overhead. Inside Postgres, such an index must map to ctids, be WAL-logged, reuse freed pages, run merges in background workers, and cooperate with VACUUM.
- Building a faster, lazier router for Postgres
PlanetScale hardMasterNeki, PlanetScale's Postgres sharding router, cuts per-query overhead by keeping PostgreSQL wire-protocol bytes intact and decoding only as much as each query requires. Results pass through as a raw byte slice and are only opened further when needed. They become row views for LIMIT, pointer slices for reordering and merge-sorting, and decoded, cached sort keys only for the columns being compared. Bind parameters and join keys are copied as length-prefixed frames, text and binary formats are preserved, and dropping columns copies contiguous runs of column frames instead of re-serializing values. Full decoding into typed values happens only when the router must compute new results, such as cross-shard aggregates. This contrasts with Vitess, which eagerly converts every row at RPC boundaries.