Re: OOM in hash join - Mailing list pgsql-hackers

From Jehan-Guillaume de Rorthais
Subject Re: OOM in hash join
Date
Msg-id 20230414134321.46fd18d3@karst
Whole thread Raw
In response to Re: OOM in hash join  (Matthias van de Meent <boekewurm+postgres@gmail.com>)
Responses Re: OOM in hash join
List pgsql-hackers
On Fri, 14 Apr 2023 13:21:05 +0200
Matthias van de Meent <boekewurm+postgres@gmail.com> wrote:

> On Fri, 14 Apr 2023 at 12:59, Konstantin Knizhnik <knizhnik@garret.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,



pgsql-hackers by date:

Previous
From: Nishant Sharma
Date:
Subject: postgres_fdw: wrong results with self join + enable_nestloop off
Next
From: Robert Haas
Date:
Subject: Re: Should we remove vacuum_defer_cleanup_age?