Global memory or local memory? (was Re: work_mem)

Поиск
Список
Период
Сортировка
От Ron
Тема Global memory or local memory? (was Re: work_mem)
Дата
Msg-id 852027d8-bc23-692e-8330-dc09d0f03af9@gmail.com
обсуждение исходный текст
Ответ на Re: work_mem  (MichaelDBA <MichaelDBA@sqlexec.com>)
Ответы Re: Global memory or local memory? (was Re: work_mem)
Список pgsql-admin
On 4/2/21 7:49 AM, MichaelDBA wrote:
That is a common misconception.  It is not one work_mem buffer per SQL, but one work_mem buffer per required operation within that SQL.  So you can have manner work_mem buffers per SQL statement!

Right from the official docs:
work_mem sets the 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 this value is specified without units, it is taken as kilobytes... 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 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, and hash-based processing of IN subqueries.

Regards,
Michael Vitale

If multiple users are querying the same regions of the same tables, does each process have to read the same blocks, or can they share ("oh look, some other process has already read into memory some of the data blocks I need, so I'll just share those buffers")?


--
Angular momentum makes the world go 'round.

В списке pgsql-admin по дате отправления:

Предыдущее
От: Bruce Momjian
Дата:
Сообщение: Re: work_mem
Следующее
От: "David G. Johnston"
Дата:
Сообщение: Re: Global memory or local memory? (was Re: work_mem)