pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: David Rowley <drowley@postgresql.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Have the planner consider Incremental Sort for DISTINCT
Date: Tue, 10 Jan 2023 21:26:55 +0000
Message-ID: <E1pFM91-0031tf-FN@gemulon.postgresql.org> (raw)

Have the planner consider Incremental Sort for DISTINCT

Prior to this, we only considered a full sort on the cheapest input path
and uniquifying any path which was already sorted in the required sort
order.  Here we adjust create_final_distinct_paths() so that it also
adds an Incremental Sort path on any path which has presorted keys.

Additionally, this adjusts the parallel distinct code so that we now
consider sorting the cheapest partial path and incrementally sorting any
partial paths with presorted keys.  Previously we didn't consider any
sorting for parallel distinct and only added a unique path atop any path
which had the required pathkeys already.

Author: David Rowley
Reviewed-by: Richard Guo
Discussion: https://postgr.es/m/CAApHDvo8Lz2H=42urBbfP65LTcEUOh288MT7DsG2_EWtW1AXHQ@mail.gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/3c6fc58209f24b959ee18f5d19ef96403d08f15c

Modified Files
--------------
src/backend/optimizer/plan/planner.c           | 222 ++++++++++++++-----------
src/test/regress/expected/incremental_sort.out |  13 +-
src/test/regress/expected/select_distinct.out  |  31 +++-
src/test/regress/expected/window.out           |  10 +-
src/test/regress/sql/select_distinct.sql       |   8 +
5 files changed, 173 insertions(+), 111 deletions(-)



Message-ID: <E1pFM91-0031tf-FN@gemulon.postgresql.org>
Permalink:  ../E1pFM91-0031tf-FN@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1pFM91-0031tf-FN@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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-committers@postgresql.org
  Cc: drowley@postgresql.org
  Subject: Re: pgsql: Have the planner consider Incremental Sort for DISTINCT
  In-Reply-To: <E1pFM91-0031tf-FN@gemulon.postgresql.org>
  References: <E1pFM91-0031tf-FN@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