Re: OOM in hash join

From: Jehan-Guillaume de Rorthais <jgdr(at)dalibo(dot)com>
To: Matthias van de Meent <boekewurm+postgres(at)gmail(dot)com>
Cc: Konstantin Knizhnik <knizhnik(at)garret(dot)ru>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: OOM in hash join
Date: 2023-04-14 11:43:21
Message-ID: 20230414134321.46fd18d3@karst
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, 14 Apr 2023 13:21:05 +0200
Matthias van de Meent <boekewurm+postgres(at)gmail(dot)com> wrote:

> On Fri, 14 Apr 2023 at 12:59, Konstantin Knizhnik <knizhnik(at)garret(dot)ru> wrote:
> >
> > Hi hackers,
> >
> > Too small value of work_mem cause memory overflow in parallel hash join
> > because of too much number batches.
> > There is the plan:
>
> [...]
>
> > There is still some gap between size reported by memory context sump and
> > actual size of backend.
> > But is seems to be obvious, that trying to fit in work_mem
> > sharedtuplestore creates so much batches, that them consume much more
> > memory than work_mem.

Indeed. The memory consumed by batches is not accounted and the consumption
reported in explain analyze is wrong.

Would you be able to test the latest patchset posted [1] ? This does not fix
the work_mem overflow, but it helps to keep the number of batches
balanced and acceptable. Any feedback, comment or review would be useful.

[1] https://www.postgresql.org/message-id/flat/20230408020119.32a0841b%40karst#616c1f41fcc10e8f89d41e8e5693618c

Regards,

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2023-04-14 12:30:30 Re: Should we remove vacuum_defer_cleanup_age?
Previous Message Nishant Sharma 2023-04-14 11:38:39 postgres_fdw: wrong results with self join + enable_nestloop off