Re: Short-circuit sort_inner_and_outer if there are no mergejoin clauses

From: Ashutosh Bapat <ashutosh(dot)bapat(dot)oss(at)gmail(dot)com>
To: Richard Guo <guofenglinux(at)gmail(dot)com>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Short-circuit sort_inner_and_outer if there are no mergejoin clauses
Date: 2024-04-25 11:25:34
Message-ID: CAExHW5tw6sfE3adbXwUwztPUFkGNCUVHF41rt+X1bZzYNHwCtg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu, Apr 25, 2024 at 12:50 PM Richard Guo <guofenglinux(at)gmail(dot)com> wrote:

>
> On Wed, Apr 24, 2024 at 5:13 PM Richard Guo <guofenglinux(at)gmail(dot)com>
> wrote:
>
>> In sort_inner_and_outer, we create mergejoin join paths by explicitly
>> sorting both relations on each possible ordering of the available
>> mergejoin clauses. However, if there are no available mergejoin
>> clauses, we can skip this process entirely. It seems that this is a
>> relatively common scenario. Checking the regression tests I noticed
>> that there are a lot of cases where we would arrive here with an empty
>> mergeclause_list.
>>
>
> FWIW, during the run of the core regression tests, I found that we enter
> sort_inner_and_outer with an empty mergeclause_list a total of 11064
> times. Out of these occurrences, there are 293 instances where the join
> type is JOIN_UNIQUE_OUTER, indicating the need to create a UniquePath
> for the outer path. Similarly, there are also 293 instances where the
> join type is JOIN_UNIQUE_INNER, indicating the need to create a
> UniquePath for the inner path.
>

Quickly looking at the function, the patch would make it more apparent that
the function is a noop when mergeclause_list is empty. I haven't looked
closely to see if creating unique path nonetheless is useful somewhere
else. Please add to the next commitfest. If the patch shows some measurable
performance improvement, it would become more attractive.

--
Best Wishes,
Ashutosh Bapat

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Daniel Gustafsson 2024-04-25 11:51:47 Re: Doc anchors for COPY formats
Previous Message Dagfinn Ilmari Mannsåker 2024-04-25 11:23:18 Doc anchors for COPY formats