agora inbox for pgsql-committers@postgresql.org  
help / color / mirror / Atom feed
From: David Rowley <drowley@postgresql.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Show estimated number of groups for Incremental Sort in EXPLAIN
Date: Tue, 11 Aug 2026 01:30:27 +0000
Message-ID: <E1wtbJy-000000003d5-0SsV@gemulon.postgresql.org> (raw)

Show estimated number of groups for Incremental Sort in EXPLAIN

Incremental Sort's costs heavily depend on the estimated number of input
groups with equal presorted key values.  Overestimations can cause the
planner to choose Incremental Sort over Sort when Sort would have
been a better choice.

Here, we add the planner's estimate to EXPLAIN to allow easier
understanding of why Incremental Sort has been chosen.

Author: Ilia Evdokimov <ilya.evdokimov@tantorlabs.com>
Reviewed-by: Enrique Sánchez <enriqueesanchz@gmail.com>
Reviewed-by: David Rowley <dgrowleyml@gmail.com>
Reviewed-by: solai v <solai.cdac@gmail.com>
Discussion: https://postgr.es/m/10682fef-3748-43f5-a932-7adcdd9bd2b8%40tantorlabs.com

Branch
------
master

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

Modified Files
--------------
doc/src/sgml/perform.sgml               |  1 +
src/backend/commands/explain.c          |  5 +++++
src/backend/optimizer/path/costsize.c   | 16 +++++++++++++---
src/backend/optimizer/plan/createplan.c |  4 +++-
src/backend/optimizer/util/pathnode.c   |  6 ++++--
src/include/nodes/pathnodes.h           |  1 +
src/include/nodes/plannodes.h           |  2 ++
src/include/optimizer/cost.h            |  3 ++-
8 files changed, 31 insertions(+), 7 deletions(-)



Message-ID: <E1wtbJy-000000003d5-0SsV@gemulon.postgresql.org>
Permalink:  ../E1wtbJy-000000003d5-0SsV@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1wtbJy-000000003d5-0SsV@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: drowley@postgresql.org, pgsql-committers@lists.postgresql.org
  Subject: Re: pgsql: Show estimated number of groups for Incremental Sort in EXPLAIN
  In-Reply-To: <E1wtbJy-000000003d5-0SsV@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 agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox