hash_mem_multiplier
Multiplier on work_mem for hash joins and hash aggregates.
- Predeterminado
2.0- Range
- 1 to 1000
- Restart needed
- No
- Default checked on
- PostgreSQL 18
Lo que hace
Hash tables degrade more sharply than sorts when they spill, so PostgreSQL lets them use more memory: the limit for a hash node is work_mem x hash_mem_multiplier.
Valor predeterminado
2.0. 2.0 since PostgreSQL 15 (it was 1.0 when introduced in 13). Same in PostgreSQL 18.
Check the current value
SHOW hash_mem_multiplier; SELECT setting, unit, boot_val, context, source, pending_restart FROM pg_settings WHERE name = 'hash_mem_multiplier';
Change it
SET hash_mem_multiplier = 3; -- this session ALTER ROLE reporting SET hash_mem_multiplier = 3; -- new sessions of one role ALTER SYSTEM SET hash_mem_multiplier = 3; 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
If hash aggregates or hash joins spill while sorts are fine, raise this instead of raising work_mem for everything.
What can go wrong
The same multiplication risk as work_mem: each hash node in each worker can use the full amount.
Questions about hash_mem_multiplier
What is the default value of hash_mem_multiplier in PostgreSQL?
2.0. 2.0 since PostgreSQL 15 (it was 1.0 when introduced in 13). Same in PostgreSQL 18.
Does changing hash_mem_multiplier 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 hash_mem_multiplier?
If hash aggregates or hash joins spill while sorts are fine, raise this instead of raising work_mem for everything.
Back to all PostgreSQL settings, or check the PostgreSQL manual for every option.
Check hash_mem_multiplier 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.