This variable sets the default TOAST compression method for values of compressible columns.
At a glance
| Property | Value |
|---|---|
| Parameter | default_toast_compression |
| Category | Client Connection Defaults |
| Default | lz4 |
| Value type | enum |
| Change scope | Per-session (SET) |
| Available in | PostgreSQL 14, 15, 16, 17, 18, 19 (added in 14) |
What it does
This variable sets the default TOAST compression method for values of compressible columns. (This can be overridden for individual columns by setting the COMPRESSION column option in CREATE TABLE or ALTER TABLE.) The supported compression methods are pglz and (if PostgreSQL was compiled with –with-lz4) lz4. The default is lz4 (if available); otherwise, pglz.
(Description quoted from the official PostgreSQL documentation.)
How to apply a change
Can be set per session with SET, per role/database with ALTER ROLE/DATABASE ... SET, or globally in postgresql.conf.
Inspect the current value and source with SHOW default_toast_compression; or SELECT name, setting, unit, context, source FROM pg_settings WHERE name = 'default_toast_compression';.
Tuning guidance
This sets a session default (locale, formatting, search path or transaction behaviour) rather than a performance knob. Set it per role or database with ALTER ROLE/DATABASE ... SET so the right default follows the right workload, and prefer setting it explicitly in the application for behaviour the query results depend on.