Re: BUG #18172: High memory usage in tSRF function context

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: sk(at)zsrv(dot)org
Cc: pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: BUG #18172: High memory usage in tSRF function context
Date: 2023-10-28 03:19:02
Message-ID: 1736370.1698463142@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

PG Bug reporting form <noreply(at)postgresql(dot)org> writes:
> While researching several cases of OOM, I discovered an atypically high
> memory consumption in this case:
> ...
> The first query consumes much more memory; note that it refers to a
> non-existent json key. Querying for a key that exists in JSON or checking
> for the existence of a key in where clause corrects memory consumption.

Thanks for the report! It seems that ExecProjectSet neglected to
think hard about what happens when the SRF returns zero rows, so
it leaks whatever memory the SRF expression might have leaked.
The attached fixes it for me.

regards, tom lane

Attachment Content-Type Size
v1-fix-zero-rows-leak-in-ExecProjectSet.patch text/x-diff 1.3 KB

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Andrei Lepikhov 2023-10-28 06:59:23 Re: BUG #18170: Unexpected error: no relation entry for relid 3
Previous Message Alexander Korotkov 2023-10-27 21:12:02 Re: BUG #18170: Unexpected error: no relation entry for relid 3