Subject: work_mem memory usage statistics

From: Loles <[email-masked]>
Date: Tue, 15 Oct 2024 20:45:30 +0200

Hi team,

Is there any statistics table or view in the PostgreSQL catalog, extension,
or similar that collects and displays work_mem memory usage statistics? It
would be interesting to know the use of the work_mem by user, application
and/or database.

Thanks in advance.

Loles

---

From: Muhammad Ikram <[email-masked]>
Date: Wed, 16 Oct 2024 08:37:27 +0500

Hi,

- No built-in routine or extension is there to show aggregation of work_mem
for any query, as it is dynamically allocated.
- If work_mem requirement exceeds then it spills to disk, which can be
monitored through logs. Use log_temp_files and log_statement_stats to see
temp files, their size may give clues.
- pg_stat_statements and pg_stat_activity may also help in getting an idea
about which queries are taking more time and their consumption of shared
blocks etc.

Regards,
Ikram

On Tue, Oct 15, 2024 at 11:46 PM Loles <[email-masked]> wrote:

> Hi team,
>
> Is there any statistics table or view in the PostgreSQL catalog,
> extension, or similar that collects and displays work_mem memory usage
> statistics? It would be interesting to know the use of the work_mem by
> user, application and/or database.
>
> Thanks in advance.
>
> Loles
>