Re: small temp files - Mailing list pgsql-admin

From Paul Smith*
Subject Re: small temp files
Date
Msg-id fe4b82fa-9907-43f9-b6ff-e1cbc768158d@pscs.co.uk
Whole thread Raw
In response to Re: small temp files  (Scott Ribe <scott_ribe@elevated-dev.com>)
Responses Re: small temp files
List pgsql-admin
On 22/07/2024 14:28, Scott Ribe wrote:
I understand those things--my question is why, with work_mem set to 128MB, I would see tiny temp files (7452 is common, as is 102, and I've seen as small as 51).

From the manual:

"Note that a complex query might perform several sort and hash operations at the same time, with each operation generally being allowed to use as much memory as this value specifies before it starts to write data into temporary files. Also, several running sessions could be doing such operations concurrently. Therefore, the total memory used could be many times the value of work_mem; it is necessary to keep this fact in mind when choosing the value. Sort operations are used for ORDER BY, DISTINCT, and merge joins. Hash tables are used in hash joins, hash-based aggregation, memoize nodes and hash-based processing of IN subqueries."

So, if it's doing lots of joins, there may be lots of bits of temporary data which together add up to more than work_mem. AIUI PostgreSQL doesn't necessarily shove all the temporary data for one query into one file, it may have multiple smaller files for the data for a single query.

pgsql-admin by date:

Previous
From: Scott Ribe
Date:
Subject: Re: small temp files
Next
From: Antoine Dussarps
Date:
Subject: [Help Request][dpage/pgadmin4] - Issue with docker image and SSO - OSError: Could not find a suitable TLS CA certificate bundle, invalid path: False