// postgresql · temporary storage

temp_file_limit

Most temporary-file space one process may use; -1 is unlimited.

Predeterminado
-1 (unlimited)
Range
-1 to 2TB, in kB
Restart needed
No
Default checked on
PostgreSQL 18

Lo que hace

Stops a single runaway sort or hash join from filling the disk. A query that exceeds it is cancelled.

Valor predeterminado

-1 (unlimited). -1 (PostgreSQL 18).

Check the current value

SHOW temp_file_limit;

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

Change it

SET temp_file_limit = '50GB';   -- this session

ALTER SYSTEM SET temp_file_limit = '50GB';
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

On shared servers where one bad query filling the data volume would take the database down.

What can go wrong

Large legitimate reports fail if set too low.

Questions about temp_file_limit

What is the default value of temp_file_limit in PostgreSQL?

-1 (unlimited). -1 (PostgreSQL 18).

Does changing temp_file_limit 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 temp_file_limit?

On shared servers where one bad query filling the data volume would take the database down.

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

// one client for every engine

Check temp_file_limit 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.