Configuration parameter

hash_mem_multiplier — PostgreSQL Configuration Parameter

Category Memory Default 2.0 Unit boolean / enum / numeric Change scope Per-session (SET)

Multiplier applied to work_mem for hash-based operations.

At a glance

Property Value
Parameter hash_mem_multiplier
Category Memory
Default 2.0
Value type boolean / enum / numeric
Change scope Per-session (SET)

What it does

Hash operations may use work_mem x hash_mem_multiplier before spilling. Default is 2.0 since PostgreSQL 15, reflecting that hashes benefit more from memory than sorts.

How to apply a change

Can be set per session with SET, per role/database with ALTER ROLE/DATABASE ... SET, or globally in postgresql.conf.

Inspect the current value and source with SHOW hash_mem_multiplier; or SELECT name, setting, unit, context, source FROM pg_settings WHERE name = 'hash_mem_multiplier';.

Tuning guidance

Raise (e.g. 3.0-4.0) when hash joins/aggregates spill to disk but you do not want to inflate sort memory. Pair with monitoring of temp-file usage.

Reference

PostgreSQL documentation — Memory configuration.

Was this helpful?

← All configuration parameters