# log_temp_files

> log_temp_files is the PostgreSQL setting that controls whether PostgreSQL logs the use of temporary files larger than this number of kilobytes.
---

> [!NOTE]
> **Fact — official short description:** “Log the use of temporary files larger than this number of kilobytes.”

## Identity {#identity}

| Field | Value | Meaning |
| --- | --- | --- |
| Type | `integer` | Upstream pg_settings type |
| Context | `superuser` | Settable at runtime by a superuser |
| Unit | `kB` | Raw unit |
| Range | `-1` – `2147483647` | Raw limits in the last observed version |
| Enum values | — | — for non-enum types |
| Category | Reporting and Logging / What to Log | Upstream classification |
| Latest boot value | `-1` | -1 kB |
{.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 | `-1` | `kB` | -1 kB |
{.full-width caption="Measured PG9.0–19 Beta 3 boot defaults"}

## How it works {#mechanism}

log_temp_files logs the use of temporary files larger than this number of kilobytes. -1 disables logging temporary files. 0 means log all temporary files. A temporary file is reported when it is deleted, with its name and size; -1 disables records and zero includes every file.

log_temp_files is a SUPERUSER-context setting. Superuser or a role granted the appropriate SET privilege can change it for a session, while ALTER ROLE or ALTER DATABASE can establish a default for future sessions.

It changes emitted diagnostic data rather than query semantics, but volume, sensitive content, log_line_prefix, destinations, collector throughput, and retention determine operational cost and usefulness.

## Tuning advice {#tuning-advice}

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

| Workload | Guidance |
| --- | --- |
| OLTP | Tune log_temp_files against an explicit observability question and a measured log-volume budget. Prefer selective thresholds, sampling, or role-level overrides over indiscriminate capture. |
| OLAP | Analytical jobs can justify richer log_temp_files telemetry, but account for long statements, large bind values, and bursty completion patterns in the log pipeline. |
| Small nodes | Keep log_temp_files useful but bounded: verify disk, collector, retention, and redaction capacity before increasing detail or frequency. |
{.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 | `1024` | different | `1024` |
| OLAP | `1024` | different | `1024` |
| CRIT | `1024` | different | `1024` |
| TINY | `1024` | different | `1024` |
{.full-width}

> [!CAUTION]
> **Advice — pending human review.** Fact from the current Pigsty template projection: OLTP: PG9.0–19 Beta 3 = 1024 (dcs); OLAP: PG9.0–19 Beta 3 = 1024 (dcs); CRIT: PG9.0–19 Beta 3 = 1024 (dcs); TINY: PG9.0–19 Beta 3 = 1024 (dcs). Advice, pending human review — Editorial inference: A 1 MiB threshold surfaces meaningful executor spills while filtering very small temporary files.

## Common pitfalls {#common-pitfalls}

- Changing log_temp_files in one session and assuming role defaults, database defaults, or other pooled sessions changed with it.
- Enabling richer logging without budgeting collector throughput, storage, retention, and downstream query cost.
- Writing SQL text, bind values, identities, or host data without a redaction and access-control policy.
- Changing log_temp_files globally without a rollback plan and a client or operational compatibility test.

## Related parameters {#related-parameters}

[`log_checkpoints`](/parameters/log-checkpoints/) · [`log_autovacuum_min_duration`](/parameters/log-autovacuum-min-duration/) · [`log_lock_waits`](/parameters/log-lock-waits/) · [`log_lock_failures`](/parameters/log-lock-failures/) · [`log_replication_commands`](/parameters/log-replication-commands/)

## References {#references}

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