Re: [HACKERS] advanced partition matching algorithm for partition-wise join
Etsuro Fujita <etsuro.fujita@gmail.com>
From: Etsuro Fujita <etsuro.fujita@gmail.com>
To: amul sul <sulamul@gmail.com>
Cc: Robert Haas <robertmhaas@gmail.com>,
Thomas Munro <thomas.munro@gmail.com>, Amit Langote <Langote_Amit_f8@lab.ntt.co.jp>, Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>, Rajkumar Raghuwanshi <rajkumar.raghuwanshi@enterprisedb.com>, Etsuro Fujita <fujita.etsuro@lab.ntt.co.jp>,
Dmitry Dolgov <9erthalion6@gmail.com>, Thomas Munro <thomas.munro@enterprisedb.com>,
Antonin Houska <ah@cybertec.at>, PostgreSQL-development <pgsql-hackers@postgresql.org>
Date: 2019-10-31T09:49:26Z
Lists: pgsql-hackers
Commits
Same data as JSON:
GET /api/v1/messages/:b64id/commits
the thread's linked commits as JSON, with link sources.
API reference →
-
Suppress unused-variable warning.
- 401418ca6a68 13.0 landed
-
Allow partitionwise joins in more cases.
- c8434d64ce03 13.0 landed
-
Avoid crash in partitionwise join planning under GEQO.
- 7ad6498fd5a6 12.0 cited
- d70c147fa217 11.3 cited
-
Disable support for partitionwise joins in problematic cases.
- 7cfdc77023ad 12.0 cited
-
Add plan_cache_mode setting
- f7cb2842bf47 12.0 cited
-
Add test for partitionwise join involving default partition.
- 4513d3a4be0b 12.0 cited
-
Revise API for partition_rbound_cmp/partition_rbound_datum_cmp.
- b0229235564f 11.0 landed
Attachments
- modify-partbounds-changes-2.patch (application/octet-stream) patch
On Tue, Oct 29, 2019 at 7:29 PM Etsuro Fujita <etsuro.fujita@gmail.com> wrote:
> On Fri, Oct 25, 2019 at 6:59 PM amul sul <sulamul@gmail.com> wrote:
> > On Wed, Oct 16, 2019 at 6:20 PM Etsuro Fujita <etsuro.fujita@gmail.com> wrote:
> >> So I'd like to propose to introduce separate functions like
> >> process_outer_partition() and process_inner_partition() in the
> >> attached, instead of handle_missing_partition(). (I added a fast path
> >> to these functions that if both outer/inner sides have the default
> >> partitions, give up on merging partitions. Also, I modified the
> >> caller sites of proposed functions so that they call these if
> >> necessary.)
>
> > Agree -- process_outer_partition() & process_inner_partition() approach looks
> > much cleaner than before.
> > Note that LHS numbers are the line numbers in your previously posted patch[1].
> >
> > 455 + if (inner_has_default ||
> > 456 + jointype == JOIN_LEFT ||
> > 457 + jointype == JOIN_ANTI ||
> > 458 + jointype == JOIN_FULL)
> > 459 + {
> > 460 + if (!process_outer_partition(&outer_map,
> >
> > 512 + if (outer_has_default || jointype == JOIN_FULL)
> > 513 + {
> > 514 + if (!process_inner_partition(&outer_map,
> >
> > How about adding these conditions to the else block of process_outer_partition()
> > & process_inner_partition() function respectively so that these functions can be
> > called unconditionally? Thoughts/Comments?
>
> I'm not sure that's a good idea; these functions might be called many
> times, so I just thought it would be better to call these functions
> conditionally, to avoid useless function call overhead.
The overhead might be small, but isn't zero, so I still think that we
should call these functions if necessary.
> > 456 + jointype == JOIN_LEFT ||
> > 457 + jointype == JOIN_ANTI ||
> > 458 + jointype == JOIN_FULL)
> >
> > Also, how about using IS_OUTER_JOIN() instead. But we need an assertion to
> > restrict JOIN_RIGHT or something.
>
> Seems like a good idea.
Done.
> > For the convenience, I did both aforesaid changes in the attached delta patch that
> > can be applied atop of your previously posted patch[1]. Kindly have a look & share
> > your thoughts, thanks.
>
> Thanks for the patch!
>
> > 1273 + * *next_index is incremented when creating a new merged partition associated
> > 1274 + * with the given outer partition.
> > 1275 + */
> >
> > Correction: s/outer/inner
> > ---
> >
> > 1338 + * In range partitioning, if the given outer partition is already
> > 1339 + * merged (eg, because we found an overlapping range earlier), we know
> > 1340 + * where it fits in the join result; nothing to do in that case. Else
> > 1341 + * create a new merged partition.
> >
> > Correction: s/outer/inner.
> > ---
> >
> > 1712 /*
> > 1713 * If the NULL partition was missing from the inner side of the join,
> >
> > s/inner side/outer side
> > --
>
> Good catch! Will fix.
Done.
I also added some assertions to process_outer_partition() and
process_inner_partition(), including ones as proposed in your patch.
Attached is an updated version. If no objections, I'll merge this
with the main patch [1].
Best regards,
Etsuro Fujita
[1] https://www.postgresql.org/message-id/CAPmGK14WHKckT1P6UJV2B63TZAxPyMn8iZJ99XF=AZuNhG6vow@mail.gmail.com