pgsql: Have the planner consider Incremental Sort for DISTINCT

From: David Rowley <drowley(at)postgresql(dot)org>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Have the planner consider Incremental Sort for DISTINCT
Date: 2023-01-10 21:26:55
Message-ID: E1pFM91-0031tf-FN@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

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(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Michael Paquier 2023-01-11 00:56:56 pgsql: Avoid using tuple from syscache for update of pg_database.datfro
Previous Message Robert Haas 2023-01-10 17:46:00 pgsql: Add new GUC createrole_self_grant.