logical_decoding_work_mem
Read PG 18 manual ↗Specifies the maximum amount of memory to be used by logical decoding, before some of the decoded changes are written to local disk.
- Type
- integer
- Context
- user
- Measured default
- 64 MiB
- Unit
- kB
- Metadata snapshot
- 18
Definition PG 18 manual
Specifies the maximum amount of memory to be used by logical decoding, before some of the decoded changes are written to local disk. This limits the amount of memory used by logical streaming replication connections. It defaults to 64 megabytes (64MB). Since each replication connection only uses a single buffer of this size, and an installation normally doesn't have many such connections concurrently (as limited by max_wal_senders), it's safe to set this value significantly higher than work_mem, reducing the amount of decoded changes written to disk.
Measured default history
| Version interval | Default |
|---|---|
| 13 – 19 | 64 MiB |
Authored guidance from the GUC source snapshot; the version-specific manual above is the definition reference. View source ↗
How it works
logical_decoding_work_mem is the real memory threshold for one logical decoding stream before decoded changes are written to local temporary files. It is independent of ordinary query work_mem.
Each replication connection uses one such buffer, and concurrency is bounded by replication sender capacity rather than client sessions. Large in-progress transactions can spill and later be reread.
Raising the threshold can reduce serialization I/O for logical replication, but the cluster memory budget must multiply it by concurrent decoding streams and include output-plugin memory outside this accounting. Its user context permits session- or transaction-local changes; newly performed or newly planned work sees the value.
Operational considerations
Changing logical_decoding_work_mem without applying its documented unit and configuration context.
Optimizing an isolated benchmark while ignoring concurrent aggregate resource use.
Assuming a configured value guarantees operating-system or storage behavior.
Failing to retest startup, failover, and workload latency after the change.
Workload guidance
OLAP: Benchmark logical_decoding_work_mem with representative bulk and scan phases. Include sustained throughput, spill/writeback, and interference with other sessions, not only one operation's elapsed time.
OLTP: Change logical_decoding_work_mem only after identifying the corresponding resource bottleneck under concurrency. Budget total memory, I/O, disk, or kernel capacity rather than optimizing one process in isolation.
SMALL: Keep logical_decoding_work_mem conservative on a small host and prefer the upstream default when evidence is weak. A setting copied from a large server can consume a disproportionate share of resources.
Version history 2
- PG 18 → 19changed
- PG 12 → 13added
Related entries
Further reading
Definition snapshot: english-manuals:fae03443601bc27d4715c9dfa65… · English manual source