# temp_tablespaces

> temp_tablespaces is the PostgreSQL setting that defines the tablespace(s) to use for temporary tables and sort files.
---

> [!NOTE]
> **Fact — official short description:** “Sets the tablespace(s) to use for temporary tables and sort files.”

## Identity {#identity}

| Field | Value | Meaning |
| --- | --- | --- |
| Type | `string` | Upstream pg_settings type |
| Context | `user` | Settable by an ordinary user |
| Unit | — | Raw unit |
| Range | — | Raw limits in the last observed version |
| Enum values | — | — for non-enum types |
| Category | Client Connection Defaults / Statement Behavior | Upstream classification |
| Latest boot value | `""` | empty string |
{.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 | `""` | — | empty string |
{.full-width caption="Measured PG9.0–19 Beta 3 boot defaults"}

## How it works {#mechanism}

temp_tablespaces sets the tablespace(s) to use for temporary tables and sort files. An empty string means use the database's default tablespace. PostgreSQL uses the list for temporary relations and executor spill files, choosing among multiple entries to distribute work; permissions and existence are checked by context.

temp_tablespaces 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 | Keep temp_tablespaces aligned with schema-management policy and make important storage choices explicit in migrations. Benchmark any physical-layout change with production-shaped writes. |
| OLAP | Use temp_tablespaces deliberately for bulk objects and spill-heavy jobs, checking I/O placement, compression support, and operational tooling before adoption. |
| Small nodes | Prefer the upstream default for temp_tablespaces unless the node has a verified alternate storage path or restore requirement; simplicity reduces recovery surprises. |
{.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}

- Changing temp_tablespaces 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 temp_tablespaces 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/) · [`default_toast_compression`](/parameters/default-toast-compression/) · [`check_function_bodies`](/parameters/check-function-bodies/) · [`maintenance_work_mem`](/parameters/maintenance-work-mem/)

## References {#references}

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