Re: small temp files

Поиск
Список
Период
Сортировка
От Paul Smith*
Тема Re: small temp files
Дата
Msg-id fe4b82fa-9907-43f9-b6ff-e1cbc768158d@pscs.co.uk
обсуждение исходный текст
Ответ на Re: small temp files  (Scott Ribe <scott_ribe@elevated-dev.com>)
Ответы Re: small temp files
Список 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 по дате отправления: