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

Richard Guo <guofenglinux@gmail.com>

From: Richard Guo <guofenglinux@gmail.com>
To: Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>
Cc: PostgreSQL-development <pgsql-hackers@postgresql.org>
Date: 2024-04-26T06:57:14Z
Lists: pgsql-hackers
On Thu, Apr 25, 2024 at 7:25 PM Ashutosh Bapat <ashutosh.bapat.oss@gmail.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

Commits

  1. Short-circuit sort_inner_and_outer if there are no mergejoin clauses