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

From: Richard Guo <guofenglinux(at)gmail(dot)com>
To: Ashutosh Bapat <ashutosh(dot)bapat(dot)oss(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-26 06:57:14
Message-ID: CAMbWs4_B=C-KaD+VGuXa61XKzJa-9F+tFw4JQDdN-Ztnuxj3bA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu, Apr 25, 2024 at 7:25 PM Ashutosh Bapat <ashutosh(dot)bapat(dot)oss(at)gmail(dot)com>
wrote:

> Quickly looking at the function, the patch would make it more apparent
> that the function is a noop when mergeclause_list is empty.
>

Thanks for looking at this patch. Yes, that's what it does.

> I haven't looked closely to see if creating unique path nonetheless is
> useful somewhere else.
>

It seems that one of the side effects of create_unique_path is that it
caches the generated unique path so that we can avoid creating it
repeatedly for the same rel. But this does not seem to justify calling
create_unique_path when we know it is unnecessary.

Please add to the next commitfest.
>

Done.

> If the patch shows some measurable performance improvement, it would
> become more attractive.
>

I doubt that there is measurable performance improvement. But I found
that throughout the run of the regression tests, sort_inner_and_outer is
called a total of 44,424 times. Among these calls, there are 11,064
instances where mergeclause_list is found to be empty. This accounts
for ~1/4. I think maybe this suggests that it's worth the shortcut as
the patch does.

Thanks
Richard

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Frédéric Yhuel 2024-04-26 07:35:24 Re: New GUC autovacuum_max_threshold ?
Previous Message Michael Paquier 2024-04-26 06:21:29 Re: Sequence Access Methods, round two