# default_toast_compression

> default_toast_compression is the PostgreSQL setting that defines the default compression method for compressible values.
---

> [!NOTE]
> **Fact — official short description:** “Sets the default compression method for compressible values.”

## Identity {#identity}

| Field | Value | Meaning |
| --- | --- | --- |
| Type | `enum` | Upstream pg_settings type |
| Context | `user` | Settable by an ordinary user |
| Unit | — | Raw unit |
| Range | — | Raw limits in the last observed version |
| Enum values | `pglz`, `lz4` | — for non-enum types |
| Category | Client Connection Defaults / Statement Behavior | Upstream classification |
| Latest boot value | `lz4` | lz4 |
{.fields meta="-"}

## Lifecycle {#lifecycle}

| Fact | Value |
| --- | --- |
| First observed | PG14 |
| Present in | PG14–19 Beta 3 |
| Removed in | No |
| Introduction commit | [`bbe0a81db69b`](https://git.postgresql.org/gitweb/?p=postgresql.git;a=commit;h=bbe0a81db69bd10bd166907c3701492a29aca294) — Allow configurable LZ4 TOAST compression. |
| Commit date | 2021-03-19 |
| Discussion | [thread 1](https://postgr.es/m/20170907194236.4cefce96%40wp.localdomain) · [thread 2](https://postgr.es/m/CAFiTN-uUpX3ck%3DK0mLEk-G_kUQY%3DSNOTeqdaNRR9FMdQrHKebw%40mail.gmail.com) |

## Default history {#default-history}

| Versions | Raw `boot_val` | Unit | Human value |
| --- | --- | --- | --- |
| PG14–18 | `pglz` | — | pglz |
| PG19 Beta 3 | `lz4` | — | lz4 |
{.full-width caption="Measured PG9.0–19 Beta 3 boot defaults"}

## How it works {#mechanism}

default_toast_compression sets the default compression method for compressible values. It chooses pglz or, when compiled in, lz4 for newly written compressible values; a column COMPRESSION clause overrides the session default.

default_toast_compression is a USER-context setting. An authorized role can change it for a session, while ALTER ROLE or ALTER DATABASE can establish a default for future sessions.

It supplies a default only when SQL omits an explicit choice, so schema migrations, object-level options, privileges, and later ALTER operations can override or outlive it.

## Tuning advice {#tuning-advice}

> [!TIP]
> **Advice.** These are workload-specific starting points and must be validated with measurements.

| Workload | Guidance |
| --- | --- |
| OLTP | Benchmark pglz versus lz4 with representative wide values, update rates, CPU, WAL, and storage. Prefer explicit column COMPRESSION for important schemas over a surprising session default. |
| OLAP | LZ4 can favor faster compression and decompression when the build supports it, but measure actual compressibility and scan behavior before changing new-write policy. |
| Small nodes | Keep pglz unless CPU-versus-space measurements and package support justify lz4; changing the default does not recompress existing values. |
{.full-width}

## Pigsty {#pigsty}

Values use the fixed 8-vCPU, 32-GiB, 100-GiB SSD fixture and render the current Pigsty templates for PG19 Beta 3; this does not assert current Pigsty support for that historical or beta release.

| Template | Effective value | Versus upstream boot | Source expression |
| --- | --- | --- | --- |
| OLTP | Unmodified | — | — |
| OLAP | Unmodified | — | — |
| CRIT | Unmodified | — | — |
| TINY | Unmodified | — | — |
{.full-width}

> [!CAUTION]
> **Advice — pending human review.** Fact from the current Pigsty template projection: OLTP: PG14–19 Beta 3 unmodified; OLAP: PG14–19 Beta 3 unmodified; CRIT: PG14–19 Beta 3 unmodified; TINY: PG14–19 Beta 3 unmodified. No Pigsty-specific rationale is inferred from an absent override.

## Common pitfalls {#common-pitfalls}

- Changing default_toast_compression in one session and assuming role defaults, database defaults, or other pooled sessions changed with it.
- Expecting a changed default to rewrite existing objects or override explicit DDL clauses.
- Ignoring tablespace privileges, installed access methods or compression support, and restore portability.
- Changing default_toast_compression globally without a rollback plan and a client or operational compatibility test.

## Related parameters {#related-parameters}

[`default_table_access_method`](/parameters/default-table-access-method/) · [`default_tablespace`](/parameters/default-tablespace/) · [`temp_tablespaces`](/parameters/temp-tablespaces/) · [`check_function_bodies`](/parameters/check-function-bodies/) · [`maintenance_work_mem`](/parameters/maintenance-work-mem/)

## References {#references}

- [PostgreSQL 19 Beta 3 — default_toast_compression](https://www.postgresql.org/docs/19/runtime-config-client.html#GUC-DEFAULT-TOAST-COMPRESSION)
- [PostgreSQL 19 release notes](https://www.postgresql.org/docs/19/release-19.html)
- [Machine-readable GUC export](/data/guc.jsonl)
