# temp_buffers

> A per-session, lazily allocated buffer ceiling used only when accessing temporary tables.
---

> [!NOTE]
> **Fact — official short description:** “Sets the maximum number of temporary buffers used by each session.”

## Identity {#identity}

| Field | Value | Meaning |
| --- | --- | --- |
| Type | `integer` | Upstream pg_settings type |
| Context | `user` | Settable by an ordinary user |
| Unit | `8kB` | Raw unit |
| Range | `100` – `1073741823` | Raw limits in the last observed version |
| Enum values | — | — for non-enum types |
| Category | Resource Usage / Memory | Upstream classification |
| Latest boot value | `1024` | 8 MiB (1024 × 8kB) |
{.fields meta="-"}

## Lifecycle {#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 {#default-history}

| Versions | Raw `boot_val` | Unit | Human value |
| --- | --- | --- | --- |
| PG9.0–19 Beta 3 | `1024` | `8kB` | 8 MiB (1024 × 8kB) |
{.full-width caption="Measured PG9.0–19 Beta 3 boot defaults"}

## How it works {#mechanism}

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 {#tuning-advice}

> [!TIP]
> **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. |
{.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: 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 {#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 {#related-parameters}

[`work_mem`](/parameters/work-mem/) · [`temp_file_limit`](/parameters/temp-file-limit/) · [`temp_tablespaces`](/parameters/temp-tablespaces/) · [`max_connections`](/parameters/max-connections/) · [`log_temp_files`](/parameters/log-temp-files/)

## References {#references}

- [PostgreSQL 19 Beta 3 — temp_buffers](https://www.postgresql.org/docs/19/runtime-config-resource.html#GUC-TEMP-BUFFERS)
- [PostgreSQL 18: CREATE TEMPORARY TABLE](https://www.postgresql.org/docs/18/sql-createtable.html)
- [PostgreSQL 19 release notes](https://www.postgresql.org/docs/19/release-19.html)
- [Machine-readable GUC export](/data/guc.jsonl)
