// postgresql · logging & diagnostics

log_temp_files

Log temporary files at or above this size when they are deleted; -1 disables, 0 logs all.

Par défaut
-1 (disabled)
Range
-1 to 2TB, in kB
Restart needed
Non
Default checked on
PostgreSQL 18

Ce que cela fait

Every sort or hash that spills past work_mem creates a temp file; this shows which statements spill and by how much.

Valeur par défaut

-1 (disabled). -1 (PostgreSQL 18).

Check the current value

SHOW log_temp_files;

SELECT setting, unit, boot_val, context, source, pending_restart
FROM pg_settings
WHERE name = 'log_temp_files';

Change it

SET log_temp_files = '10MB';   -- this session

ALTER SYSTEM SET log_temp_files = '10MB';
SELECT pg_reload_conf();

No restart. Superusers, or roles granted SET on the parameter (PostgreSQL 15 and later), can SET it per session; a server-wide ALTER SYSTEM change applies after a reload (context is superuser).

When to change it

Set to a few MB when tuning work_mem.

What can go wrong

0 can be noisy on reporting servers.

Questions about log_temp_files

What is the default value of log_temp_files in PostgreSQL?

-1 (disabled). -1 (PostgreSQL 18).

Does changing log_temp_files require a restart?

No. No restart. Superusers, or roles granted SET on the parameter (PostgreSQL 15 and later), can SET it per session; a server-wide ALTER SYSTEM change applies after a reload (context is superuser).

When should I change log_temp_files?

Set to a few MB when tuning work_mem.

Back to all PostgreSQL settings, or check the PostgreSQL manual for every option.

// one client for every engine

Check log_temp_files on your own server

SQLly runs the query above against PostgreSQL and the other engines in this reference, from one desktop app on macOS, Windows and Linux.