Re: Add the ability to limit the amount of memory that can be allocated to backends.

From: David Rowley <dgrowleyml(at)gmail(dot)com>
To: James Hunter <james(dot)hunter(dot)pg(at)gmail(dot)com>
Cc: Tomas Vondra <tomas(at)vondra(dot)me>, Tomas Vondra <tomas(dot)vondra(at)enterprisedb(dot)com>, "Anton A(dot) Melnikov" <a(dot)melnikov(at)postgrespro(dot)ru>, Andres Freund <andres(at)anarazel(dot)de>, Andrei Lepikhov <a(dot)lepikhov(at)postgrespro(dot)ru>, Stephen Frost <sfrost(at)snowman(dot)net>, reid(dot)thompson(at)crunchydata(dot)com, Arne Roland <A(dot)Roland(at)index(dot)de>, "pgsql-hackers(at)lists(dot)postgresql(dot)org" <pgsql-hackers(at)lists(dot)postgresql(dot)org>, vignesh C <vignesh21(at)gmail(dot)com>, Justin Pryzby <pryzby(at)telsasoft(dot)com>, Ibrar Ahmed <ibrar(dot)ahmad(at)gmail(dot)com>, "stephen(dot)frost" <stephen(dot)frost(at)crunchydata(dot)com>
Subject: Re: Add the ability to limit the amount of memory that can be allocated to backends.
Date: 2024-12-30 22:56:42
Message-ID: CAApHDvqQufvtL1XV6vMDdZ5T=0jQSzc13txfy-EvXy-RR4xF3g@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, 31 Dec 2024 at 10:11, James Hunter <james(dot)hunter(dot)pg(at)gmail(dot)com> wrote:
> Does PostgreSQL currently rescan Hash Joins when they are "no longer
> needed," to free work_mem early? If so, then I would try to reuse this
> existing logic to decide which nodes need work_mem concurrently.
>
> If not, then all nodes that use work_mem actually use it
> "concurrently," because we don't free that work_mem until we call
> ExecutorEnd().

The problem with that statement is that Hash Join isn't the only node
type that uses work_mem. Plenty of other node types do. Have a look
at MultiExecBitmapOr(). You can see logic there that does tbm_free()
after the tbm_union() call. Going by that, it seems there is at least
one place where we might free some work_mem memory before allocating
another lot.

David

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Jelte Fennema-Nio 2024-12-30 22:57:14 Re: RFC: Allow EXPLAIN to Output Page Fault Information
Previous Message Bruce Momjian 2024-12-30 21:58:26 Re: Backport of CVE-2024-10978 fix to older pgsql versions (11, 9.6, and 9.4)