temp_buffers
Per-session buffer cache for temporary tables.
- Default
8MB- Range
- 800kB to 8TB, in 8kB pages
- Restart needed
- No
- Default checked on
- PostgreSQL 18
What it does
Temporary tables bypass shared_buffers. Each session allocates up to this much, and only if it uses temporary tables.
Default value
8MB. 8MB (PostgreSQL 18).
Check the current value
SHOW temp_buffers; SELECT setting, unit, boot_val, context, source, pending_restart FROM pg_settings WHERE name = 'temp_buffers';
Change it
SET temp_buffers = '64MB'; -- this session ALTER ROLE reporting SET temp_buffers = '64MB'; -- new sessions of one role ALTER SYSTEM SET temp_buffers = '64MB'; SELECT pg_reload_conf();
No restart. Any role can SET it for a session or with SET LOCAL for one transaction; a server-wide ALTER SYSTEM change applies after a reload (context is user).
When to change it
For sessions that build large temporary tables. Set it before the session first touches a temporary table; after that, SET temp_buffers fails with an error for the rest of the session.
What can go wrong
Low: memory is only taken when used. Large values on many sessions that all use temp tables add up.
Questions about temp_buffers
What is the default value of temp_buffers in PostgreSQL?
8MB. 8MB (PostgreSQL 18).
Does changing temp_buffers require a restart?
No. No restart. Any role can SET it for a session or with SET LOCAL for one transaction; a server-wide ALTER SYSTEM change applies after a reload (context is user).
When should I change temp_buffers?
For sessions that build large temporary tables. Set it before the session first touches a temporary table; after that, SET temp_buffers fails with an error for the rest of the session.
Back to all PostgreSQL settings, or check the PostgreSQL manual for every option.
Check temp_buffers 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.