Re: PostgreSQL processes use large amount of private memory on Windows

Поиск
Список
Период
Сортировка
От Peter J. Holzer
Тема Re: PostgreSQL processes use large amount of private memory on Windows
Дата
Msg-id 20200917172659.GA417@hjp.at
обсуждение исходный текст
Ответ на PostgreSQL processes use large amount of private memory on Windows  (Øystein Kolsrud <kolsrud@gmail.com>)
Ответы Re: PostgreSQL processes use large amount of private memory on Windows  (Øystein Kolsrud <kolsrud@gmail.com>)
Список pgsql-general
On 2020-09-17 11:19:07 +0200, Øystein Kolsrud wrote:
> I have a product that uses PostgreSQL (v9.6) as database on Windows, and we
> often observe that the "shared working set" memory reported for the individual
> connection processes is quite high (around 200MB), but the "private working
> set" is relatively low (around 5 MB). I assume this is due to the processes
> utilizing the shared buffers of Postgres, and in these cases everything works
> fine as the total memory consumption on the system is quite low. But for some
> deployments we have observed that the "private working set" is around 200 MB as
> well, and in these cases the server quickly runs out of memory when the number
> of connections rises. I have never been able to reproduce this behavior myself.
[...]
> All settings typically referred to (like "work_mem" and "temp_buffers") are at
> default settings, and I have a very hard time seeing how those settings could
> add up to memory in the magnitude of 200MB.

The work_mem setting is per operation (e.g. sort, hash join, etc.), so a
complex query may use a multiple of it. However, the default is just 4 MB,
so a query would have to be very complex to use 50 times as much. Also,
that memory is freed after the query (however "freed" does not
necessarily mean "returned to the OS", it can just mean "marked as
availiable for reuse" - that depends on the C library and the OS).

What I would do:

* Set log_statement to all (warning: that can be a lot of log messages.
  It can also be a privacy/security hazard, depending on who has access
  to the server and how sensitive queries are).
* Frequently (at least once per minute) record the size of all postgres
  processes. Send an alert if one of them is "too large".

This should give you a good idea what the processes were doing at the
time they allocated that memory, so that you can reproduce the problem.

        hp

--
   _  | Peter J. Holzer    | Story must make more sense than reality.
|_|_) |                    |
| |   | hjp@hjp.at         |    -- Charles Stross, "Creative writing
__/   | http://www.hjp.at/ |       challenge!"

Вложения

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

Предыдущее
От: Jerry Sievers
Дата:
Сообщение: Re: Obvious data mismatch in View2 which basically SELECT * from View1
Следующее
От: Ben
Дата:
Сообщение: Re: Obvious data mismatch in View2 which basically SELECT * from View1