pgsql: Reduce memory used by partitionwise joins

From: Amit Langote <amitlan(at)postgresql(dot)org>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Reduce memory used by partitionwise joins
Date: 2024-03-25 09:07:57
Message-ID: E1rogJA-005XlS-Ls@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Reduce memory used by partitionwise joins

Specifically, this commit reduces the memory consumed by the
SpecialJoinInfos that are allocated for child joins in
try_partitionwise_join() by freeing them at the end of creating paths
for each child join.

A SpecialJoinInfo allocated for a given child join is a copy of the
parent join's SpecialJoinInfo, which contains the translated copies
of the various Relids bitmapsets and semi_rhs_exprs, which is a List
of Nodes. The newly added freeing step frees the struct itself and
the various bitmapsets, but not semi_rhs_exprs, because there's no
handy function to free the memory of Node trees.

Author: Ashutosh Bapat <ashutosh(dot)bapat(dot)oss(at)gmail(dot)com>
Reviewed-by: Richard Guo <guofenglinux(at)gmail(dot)com>
Reviewed-by: Amit Langote <amitlangote09(at)gmail(dot)com>
Reviewed-by: Andrey Lepikhov <a(dot)lepikhov(at)postgrespro(dot)ru>
Reviewed-by: Tomas Vondra <tomas(dot)vondra(at)enterprisedb(dot)com>
Discussion: https://postgr.es/m/CAExHW5tHqEf3ASVqvFFcghYGPfpy7o3xnvhHwBGbJFMRH8KjNw@mail.gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/5278d0a2e870c61f9374a7796b90e6f9f6a73638

Modified Files
--------------
src/backend/optimizer/path/joinrels.c | 36 +++++++++++++++++++++++++++++++++++
src/backend/optimizer/util/pathnode.c | 5 +++--
src/include/nodes/pathnodes.h | 3 +++
3 files changed, 42 insertions(+), 2 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Alexander Korotkov 2024-03-25 09:40:32 pgsql: reindexdb: Fix warning about uninitialized indices_tables_cell
Previous Message Magnus Hagander 2024-03-25 09:04:27 Re: pgsql: make dist uses git archive