Re: apply_scanjoin_target_to_paths and partitionwise join

Robert Haas <robertmhaas@gmail.com>

From: Robert Haas <robertmhaas@gmail.com>
To: Arne Roland <arne.roland@malkut.net>
Cc: Tom Lane <tgl@sss.pgh.pa.us>, Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>, Andrei Lepikhov <lepihov@gmail.com>, Jakub Wartak <jakub.wartak@enterprisedb.com>, Tomas Vondra <tomas.vondra@enterprisedb.com>, PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>, Julien Rouhaud <rjuju123@gmail.com>, Etsuro Fujita <etsuro.fujita@gmail.com>, Richard Guo <guofenglinux@gmail.com>
Date: 2025-10-29T12:47:45Z
Lists: pgsql-hackers
On Wed, Oct 29, 2025 at 6:43 AM Arne Roland <arne.roland@malkut.net> wrote:
> Richard already covered a lot. I mainly want to reiterate, that a public test case would be immensely helpful.

I agree, and said the same.

> The Q1 you mentioned sadly isn't a real test case, where I can measure performance impact. More an academic difference in costs, which I don't fully comprehend as of now.

I don't either, but maybe if I study it (or you or someone else does)
we can begin to comprehend it.

> Did you encounter a case a in production, that made you reevaluate this thread? If so a public reproducer would be very appreciated.

No, what happened is that this broke a patch I'm working on. The
details are lengthy and would take us too far away from the topic of
this thread, but the highly-compressed version is that I spent about
six hours going "wait, why the heck isn't this working?" and
eventually traced it back to the pathlist for a partitionwise join
getting zapped. I might have to bolt on some kind of a fix to un-break
that patch for now, but it's not relevant in terms of constructing a
reproducer for this problem. I think the best shot at coming up with a
reproducer here is to study the cost differences in the queries where
the plan changes with the fix, particularly Q1 from my prior email.
While I agree with you that at present that is just a numerical effect
and not a real performance effect, we don't even have an explanation
for how the numerical effect is possible. It seems like a good idea to
figure that out.

-- 
Robert Haas
EDB: http://www.enterprisedb.com



Commits

Same data as JSON: GET /api/v1/messages/:b64id/commits the thread's linked commits as JSON, with link sources. API reference →
  1. Remove redundant SET enable_partitionwise_join = on.

  2. Don't reset the pathlist of partitioned joinrels.

  3. Allow left join removals and unique joins on partitioned tables

  4. Consider fractional paths in generate_orderedappend_paths

  5. Fix handling of targetlist SRFs when scan/join relation is known empty.