Re: PostgreSQL uses huge amount of memory

From: Neimar Sierota <neimarsmo(at)gmail(dot)com>
To: Mauricio Martini <martini(dot)mauricio(at)hotmail(dot)com>
Cc: pgsql-admin(at)lists(dot)postgresql(dot)org
Subject: Re: PostgreSQL uses huge amount of memory
Date: 2023-03-08 13:29:12
Message-ID: CAOX8E_Ro9U6Qvwj8XZHbsxsviuA73RJn_nxaT=yEq2di35MZnA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

I did a test as you mentioned and in postgresql version 11 I didn't observe
any change in memory consumption while the query is executed. With version
14, running the same query, it is possible to observe a considerable
increase in memory usage during execution.
Could it be a bug in postgresql's memory management?

WITH DADOS as (
select 1
UNION ALL
SELECT 1
UNION ALL
SELECT 1
UNION ALL
...
)
select * from dados;

Em qua, 8 de mar de 2023 10:17, Mauricio Martini <
martini(dot)mauricio(at)hotmail(dot)com> escreveu:

>
> When executing a query containing WITH and more than a thousand UNION ALL,
> PostgreSQL version 14 or higher uses all server memory until it enters
> recovery mode. In tests with version 11, this behavior does not occur.
> shouldn't he respect the work_mem?
> *I know I should refactor, but what caught my attention was the fact that
> a query uses the entire resource without restriction, which does not occur
> in version 11.4, I did a test in version 15, which also occurs.
> Has anything related to memory usage in this sense been changed?
>
>
>

In response to

Responses

Browse pgsql-admin by date

  From Date Subject
Next Message Scott Ribe 2023-03-08 16:13:13 Re: PostgreSQL uses huge amount of memory
Previous Message Mauricio Martini 2023-03-08 13:04:18 PostgreSQL uses huge amount of memory