pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Richard Guo <rguo@postgresql.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Short-circuit sort_inner_and_outer if there are no mergejoin cla
Date: Tue, 30 Jul 2024 06:53:53 +0000
Message-ID: <E1sYgk5-001rAJ-2q@gemulon.postgresql.org> (raw)

Short-circuit sort_inner_and_outer if there are no mergejoin clauses

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.

This patch introduces a check for mergeclause_list at the beginning of
sort_inner_and_outer and exits the function if it is found to be
empty.  This might help skip all the statements that come before the
call to select_outer_pathkeys_for_merge, including the build of
UniquePaths in the case of JOIN_UNIQUE_OUTER or JOIN_UNIQUE_INNER.

I doubt there's any measurable performance improvement, but 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, which accounts for
approximately one-fourth.  I think this suggests that implementing
this shortcut is worthwhile.

Author: Richard Guo
Reviewed-by: Ashutosh Bapat
Discussion: https://postgr.es/m/CAMbWs48RKiZGFEd5A0JtztRY5ZdvVvNiHh0AKeuoz21F+0dVjQ@mail.gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/cc9daa09eee927c17b9409ff42fc7a0b7d6fbd9a

Modified Files
--------------
src/backend/optimizer/path/joinpath.c | 4 ++++
1 file changed, 4 insertions(+)



Message-ID: <E1sYgk5-001rAJ-2q@gemulon.postgresql.org>
Permalink:  ../E1sYgk5-001rAJ-2q@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1sYgk5-001rAJ-2q@gemulon.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-committers@postgresql.org
  Cc: rguo@postgresql.org, pgsql-committers@lists.postgresql.org
  Subject: Re: pgsql: Short-circuit sort_inner_and_outer if there are no mergejoin cla
  In-Reply-To: <E1sYgk5-001rAJ-2q@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox