Parameter · Resource Usage / Memory
temp_buffers
Sets the maximum number of temporary buffers used by each session.
- Default:
8MB - Type: integer (8kB)
- Range: 800kB … 8589934584kB
- Applies: Session (any user)
In plain words
Temporary tables are private to one session, so their pages are not kept in shared buffers but in a private cache of the session, sized by temp_buffers. If a temporary table is bigger, older pages are written out to the table's file and read back when needed.
For DBAs and operators
Memory is allocated lazily: an unused setting costs only ~64 bytes per buffer descriptor, a used buffer costs 8 kB. Can be changed with SET only before the first use of a temporary table in the session; afterwards SET is rejected: DETAIL: "temp_buffers" cannot be changed after any temporary tables have been accessed in the session.
Temp-table pages that do not fit are written to the temp table's own relation file (base/<db>/t<backend>_<relfilenode>), not to pgsql_tmp; they are not WAL-logged and are not limited by temp_file_limit. EXPLAIN (ANALYZE, BUFFERS) reports them as local hit/read/dirtied/written, and pg_stat_io has rows with context = 'normal', object = 'temp relation'.
Applications (ETL, reporting) that build big temp tables per session benefit from SET temp_buffers = '256MB' at session start. Remember it is per session: 500 sessions × a large value can add up if they all really use temp tables. Temp tables are also never vacuumed by autovacuum, so long-lived ones need manual ANALYZE/VACUUM.
How to change it
Any user can change it for their session with SET.
See it in context
Local (per-backend) memory Memory architecture Buffer manager internals