temp_buffers
Fact — official short description: “Sets the maximum number of temporary buffers used by each session.”
Identity
Lifecycle
| Fact | Value |
|---|---|
| First observed | PG9.0 (research boundary) |
| Present in | PG9.0–19 Beta 3 |
| Removed in | No |
| Introduction commit | Not asserted: predates the PG9.0 research boundary |
| Commit date | — |
| Discussion | — |
Default history
| Versions | Raw boot_val |
Unit | Human value |
|---|---|---|---|
| PG9.0–19 Beta 3 | 1024 |
8kB |
8 MiB (1024 × 8kB) |
How it works
temp_buffers controls session-local buffers for temporary-table access. It does not govern sort or hash spill files created by ordinary query execution.
A session can change the value only before its first use of a temporary table; later SET commands have no effect for that session. Buffers are allocated on demand up to the ceiling.
An unused increase still creates buffer-descriptor overhead, while each buffer actually used consumes one database block, normally 8kB. Aggregate usage therefore depends on the number of sessions actively using temporary tables.
Tuning advice
Advice. These are workload-specific starting points and must be validated with measurements.
| Workload | Guidance |
|---|---|
| OLTP | Leave the default unless the application demonstrably uses sizable temporary tables. Prefer scoped changes in the sessions that create them and set the value before first access. |
| OLAP | Raise it only for workflows that use PostgreSQL temporary tables; work_mem, not temp_buffers, is the primary control for sort and hash operations. Include session concurrency in the budget. |
| Small nodes | Keep the default and avoid globally increasing per-session ceilings. Temporary-table-heavy jobs should be isolated or adjusted locally. |
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 | — | — |
Advice — pending human review. Fact from the current Pigsty template projection: OLTP: PG9.0–19 Beta 3 unmodified; OLAP: PG9.0–19 Beta 3 unmodified; CRIT: PG9.0–19 Beta 3 unmodified; TINY: PG9.0–19 Beta 3 unmodified. No Pigsty-specific rationale is inferred from an absent override.
Common pitfalls
- Confusing temporary-table buffers with sort and hash temporary files.
- Issuing SET after the session has already accessed a temporary table.
- Ignoring multiplication across many sessions actively using temporary tables.
- Assuming a large value is fully allocated immediately; PostgreSQL grows usage on demand, though descriptor overhead remains.
Related parameters
work_mem · temp_file_limit · temp_tablespaces · max_connections · log_temp_files
References
- PostgreSQL 19 Beta 3 — temp_buffers
- PostgreSQL 18: CREATE TEMPORARY TABLE
- PostgreSQL 19 release notes
- Machine-readable GUC export