select open change scope Open full search

PG.CENTER connects PostgreSQL documentation, reference, and ecosystem knowledge. Maintained by Pigsty.

CONFIGURATION / REPORTING AND LOGGING

log_temp_files

Read PG 18 manual ↗

Controls logging of temporary file names and sizes.

Type
integer
Context
superuser
Measured default
-1 kB
Unit
kB
Metadata snapshot
18

Definition PG 18 manual

Controls logging of temporary file names and sizes. Temporary files can be created for sorts, hashes, and temporary query results. If enabled by this setting, a log entry is emitted for each temporary file, with the file size specified in bytes, when it is deleted. A value of zero logs all temporary file information, while positive values log only files whose size is greater than or equal to the specified amount of data. If this value is specified without units, it is taken as kilobytes. The default setting is -1, which disables such logging. Only superusers and users with the appropriate SET privilege can change this setting.

Measured default history
Version intervalDefault
9.0 – 19-1 kB
Analysis & operational context

Authored guidance from the GUC source snapshot; the version-specific manual above is the definition reference. View source ↗

How it works

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.

Operational considerations

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.

Workload guidance

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.

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.

SMALL: Keep log_temp_files useful but bounded: verify disk, collector, retention, and redaction capacity before increasing detail or frequency.

Version history 4
  1. PG 17 → 18changed
  2. PG 15 → 16changed
  3. PG 14 → 15changed
  4. PG 11 → 12changed

Related entries

Further reading

Definition snapshot: english-manuals:16060e6f3956aa4bc0e1373c7fc… · English manual source