work_mem
A configuration parameter specifying the maximum amount of memory available for internal sort operations and hash tables
work_mem
is a configuration parameter specifying the maximum amount of memory available for internal sort operations and hash tables, beyond which the operations will spill to disk (and risk becoming considerably slower).
work_mem
was added in PostgreSQL 8.0, replacing sort_mem
.
Default value
Default value for work_mem
is:
- PostgreSQL 9.4 and later:
4MB
- PostgreSQL 8.0 ~ PostgreSQL 9.3:
1MB
Changes to work_mem
require a reload to take effect and are effective immediately for all backends.
Change history
- PostgreSQL 9.4
- default value changed from
1MB
to4MB
(commit 848ae330)
- default value changed from
- PostgreSQL 8.0
References
- PostgreSQL documentation: work_mem
Useful links
- Let's talk a bit more about setting work_mem in #PostgreSQL - 2021 Twitter thread
- Configuring work_mem in Postgres - February 2020 blog article by David Conlin / pgMustard
- Understanding postgresql.conf : work_mem - 2011 blog article by depesz