Re: Proposal: "query_work_mem" GUC, to distribute working memory to the query's individual operators

From: Saheed Ajiboye <ajiboyeca(at)gmail(dot)com>
To: pgsql-hackers(at)lists(dot)postgresql(dot)org
Cc: 253330017(at)nileuniversity(dot)edu(dot)ng, manuelreyesbravo(at)gmail(dot)com
Subject: Re: Proposal: "query_work_mem" GUC, to distribute working memory to the query's individual operators
Date: 2026-12-02 21:19:21
Message-ID: CAGhdfNAA3cBXd2YNoPfvuYHXvh91905Zr=pCpzrgqi6HJv=WzQ@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi Manu,

On Tue, Oct 6, 2026, you wrote:
> I can share it if that is useful for judging whether the field earns its
keep.

I'd like to take you up on that. I'm a PhD student in Computer Science
working on how to divide a fixed per-query working-memory budget among the
Sort, Hash Join and Hash Aggregate nodes of a plan. The approach combines
per-operator spill-cost models, the overlap of node memory lifetimes, and a
probabilistic bound on exceeding the budget. Your per-node workmem field is
exactly the enforcement hook this needs, and pg_mem_governor would be an
important baseline.

Could you share the pg_mem_governor source (a repository link or a tarball
is fine), together with the spill-calibration scripts or data it uses, if
those are separate? I would:

- run it on your v2 patch against PostgreSQL 19 and compare it with other
allocation policies at equal budgets on TPC-H and JOB;
- credit and cite it in anything I publish; and
- post any results that bear on the Plan.workmem field back to this thread.

If there is a licence you'd like it used under, or you'd prefer I not
redistribute it, just say so.

In return I'm happy to test the patch more widely. I'm currently measuring
when Sort, Hash and HashAggregate nodes actually release their memory
during execution, and I'll share the results here.

Thanks,
Saheed Ajiboye
PhD candidate, Department of Computer Science
Nile University of Nigeria

Browse pgsql-hackers by date

  From Date Subject
Next Message brianmacy 2026-12-02 21:23:18 [PATCH v1] Open only the target segment to reach existing blocks
Previous Message Kirill Reshke 2026-12-02 21:08:59 DROP SUBSCRIPTION deadlock with ALTER SUBSCRIPTION OWNER TO