Postgres 19 is switching its default TOAST compression algorithm from pglz to LZ4. The post covers the history of Postgres compression starting from version 7.0, explains why pglz was originally built (speed, minimal memory, no external dependencies), and details why LZ4 is a better fit for modern hardware — roughly 8× faster compression and better ratios due to a larger 64 kB sliding window. It also walks through Postgres storage strategies (EXTENDED, PLAIN, EXTERNAL, MAIN), the varlena format for variable-length types, the step-by-step compression decision tree Postgres uses when writing rows, and how compression works in B-tree indexes including the 510-byte threshold and the 2704-byte maximum index row size limit.
Table of contents
History of Postgres CompressionTOAST with pglzWhy move from pglz to LZ4?Postgres storage strategiesThe varlena formatThe compression decision treeCompression in indexesThe future of compression in Postgres6K Impressions