From: Richard Guo <rguo@postgresql.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Track the number of presorted outer pathkeys in MergePath
Date: Thu, 08 May 2025 09:22:39 +0000
Message-ID: <E1uCxSg-000klp-2W@gemulon.postgresql.org> (raw)
Track the number of presorted outer pathkeys in MergePath
When creating an explicit Sort node for the outer path of a mergejoin,
we need to determine the number of presorted keys of the outer path to
decide whether explicit incremental sort can be applied. Currently,
this is done by repeatedly calling pathkeys_count_contained_in.
This patch caches the number of presorted outer pathkeys in MergePath,
allowing us to save several calls to pathkeys_count_contained_in. It
can be considered a complement to the changes in commit 828e94c9d.
Reported-by: David Rowley <dgrowleyml@gmail.com>
Author: Richard Guo <guofenglinux@gmail.com>
Reviewed-by: Tender Wang <tndrwang@gmail.com>
Discussion: https://postgr.es/m/CAApHDvqvBireB_w6x8BN5txdvBEHxVgZBt=rUnpf5ww5P_E_ww@mail.gmail.com
Branch
------
master
Details
-------
https://git.postgresql.org/pg/commitdiff/c06e909c26f070dee78f73c35565d6f4a4ffdcda
Modified Files
--------------
src/backend/foreign/foreign.c | 5 +--
src/backend/optimizer/path/costsize.c | 59 +++++++++++++++----------------
src/backend/optimizer/path/joinpath.c | 28 ++++++++++++---
src/backend/optimizer/plan/createplan.c | 61 +++++++++++++++++----------------
src/backend/optimizer/util/pathnode.c | 5 ++-
src/include/nodes/pathnodes.h | 8 +++++
src/include/optimizer/cost.h | 1 +
src/include/optimizer/pathnode.h | 3 +-
8 files changed, 104 insertions(+), 66 deletions(-)
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: Track the number of presorted outer pathkeys in MergePath
In-Reply-To: <E1uCxSg-000klp-2W@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