Re: Memory consumed by child SpecialJoinInfo in partitionwise join planning
Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>
From: Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>
To: Amit Langote <amitlangote09@gmail.com>
Cc: Richard Guo <guofenglinux@gmail.com>,
pgsql-hackers <pgsql-hackers@postgresql.org>
Date: 2023-09-27T11:07:38Z
Lists: pgsql-hackers
Attachments
- 0003-Address-Amit-s-comments-20230927.patch (text/x-patch) patch 0003
- 0002-Reduce-memory-used-by-child-SpecialJoinInfo-20230927.patch (text/x-patch) patch 0002
- 0001-Report-memory-used-for-planning-a-query-in--20230927.patch (text/x-patch) patch 0001
On Wed, Sep 27, 2023 at 2:30 PM Amit Langote <amitlangote09@gmail.com> wrote: > > Here are some comments. Thanks for your review. > > Please merge 0003 into 0002. Done. > > + /* > + * But the list of operator OIDs and the list of expressions may be > + * referenced somewhere else. Do not free those. > + */ > > I don't see build_child_join_sjinfo() copying any list of OIDs, so I'm > not sure what the comment is referring to. Also, instead of "the list > of expressions", it might be more useful to mention semi_rhs_expr, > because that's the only one being copied. list of OID is semi_operators. It's copied as is from parent SpecialJoinInfo. But the way it's mentioned in the comment is confusing. I have modified the prologue of function to provide a general guidance on what can be freed and what should not be. and then specific examples. Let me know if this is more clear. > > The comment for SpecialJoinInfo mentions that they are stored in > PlannerInfo.join_info_list, but the child SpecialJoinInfos used by > partitionwise joins are not, which I noticed has not been mentioned > anywhere. Should we make a note of that in the SpecialJoinInfo's > comment? Good point. Since SpecialJoinInfos for JOIN_INNER are mentioned there, it makes sense to mention transient child SpecialJoinInfos as well. Done. > > Just out of curiosity, is their not being present in join_info_list > problematic in some manner, such as missed optimization opportunities > for child joins? I noticed there is a loop over join_info_list in > add_paths_to_join_rel(), which does get called for child joinrels. I > know this a bit off-topic for the thread, but thought to ask in case > you've already thought about it. The function has a comment and code to take care of this at the very beginning /* * PlannerInfo doesn't contain the SpecialJoinInfos created for joins * between child relations, even if there is a SpecialJoinInfo node for * the join between the topmost parents. So, while calculating Relids set * representing the restriction, consider relids of topmost parent of * partitions. */ if (joinrel->reloptkind == RELOPT_OTHER_JOINREL) joinrelids = joinrel->top_parent_relids; else joinrelids = joinrel->relids; PFA latest patch set 0001 - same as previous patch set 0002 - 0002 and 0003 from previous patch set squashed together 0003 - changes addressing above comments. -- Best Wishes, Ashutosh Bapat
Commits
-
Code review for 6190d828cd2
- 0f7863afef67 17.0 landed
-
Do not translate dummy SpecialJoinInfos for child joins
- 6190d828cd25 17.0 landed
-
Reduce memory used by partitionwise joins
- 5278d0a2e870 17.0 landed
-
Remove dummy_spinlock
- 55627ba2d334 17.0 cited