Postgres Work Mem
If sorting or hash table needs more memory than permitted by work_mem , then PostgreSQL will use temp files on disk to perform such operations. I know I can use SHOW WORK_MEM; in psql to view the value of the connection currently used. Sets the base maximum amount of memory to be used by a query operation (such as a sort or hash table) before writing to temporary disk files. If a single query execution plan contains more than one memory-hungry execution steps, this query can use. PostgreSQL uses the value of work_mem setting as the limit on how much memory each query may use for each sorting operation or hash table. Fine-tune work_mem in PostgreSQL to get the best performance. In Amazon Relational Database Service (Amazon RDs) for PostgreSQL and Amazon Aurora PostgreSQL-Compatible Edition, the parameter that dictates how much of memory can be allocated for a sort is work_mem. Our Support Team is here to demonstrate how to use work_mem to get the most out of it. If sorting requires more than the allocated work_mem, it leads to physical I. work_mem (integer) Specifies the amount of memory to be used by internal sort operations and hash tables before writing to temporary disk files. Note that for a complex query, several sort or hash operations might be running in parallel; each operation will be allowed to use as much memory as this.