Parameter · Client Connection Defaults / Statement Behavior
default_toast_compression
Sets the default compression method for compressible values.
- Default:
pglz - Type: enum
- Values: pglz · lz4
- Applies: Session (any user)
In plain words
Large values (long text, JSON, bytea) are compressed and possibly moved out of line (TOAST). This picks the algorithm for new values: the classic pglz or the faster lz4.
For DBAs and operators
Applies when a value is compressed and its column has no explicit COMPRESSION clause. lz4 requires a server built with --with-lz4 (standard in PGDG packages); it compresses and especially decompresses much faster than pglz, with similar or slightly lower ratio.
Existing values keep the method they were written with; changing the setting or ALTER TABLE … ALTER COLUMN … SET COMPRESSION affects only new values. A table can therefore contain both. Check with SELECT pg_column_compression(col), count(*) FROM t GROUP BY 1. Rewriting values (for example VACUUM FULL) does not recompress them.
Values are only compressed when a row exceeds about 2 kB (TOAST_TUPLE_THRESHOLD). For JSON-heavy workloads lz4 is a common, safe improvement. pg_dump records column-level methods (skip with --no-toast-compression).
How to change it
Any user can change it for their session with SET.