pgsql: Allow Incremental Sorts on GiST and SP-GiST indexes

From: David Rowley <drowley(at)postgresql(dot)org>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Allow Incremental Sorts on GiST and SP-GiST indexes
Date: 2023-07-04 11:09:09
Message-ID: E1qGdu9-001rUo-P9@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Allow Incremental Sorts on GiST and SP-GiST indexes

Previously an "amcanorderbyop" index would only be used when the index
could provide sorted results which satisfied all query_pathkeys. Here
we relax this so that we also allow these indexes to be considered by the
planner when they only provide partially sorted results. This allows the
planner to later consider making use of an Incremental Sort to satisfy the
remaining pathkeys. This change is particularly useful for KNN-type
queries which contain a LIMIT clause and an additional ORDER BY clause for
a non-indexed column.

Author: Miroslav Bendik
Reviewed-by: Richard Guo, David Rowley
Discussion: https://postgr.es/m/CAPoEpV0QYDtzjwamwWUBqyWpaCVbJV2d6qOD7Uy09bWn47PJtw%40mail.gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/625d5b3ca0968c1d8c080d5210f7209184c0d134

Modified Files
--------------
src/backend/optimizer/path/indxpath.c | 53 ++++++++++++++------------
src/test/regress/expected/incremental_sort.out | 33 ++++++++++++++++
src/test/regress/sql/incremental_sort.sql | 16 ++++++++
3 files changed, 77 insertions(+), 25 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Peter Eisentraut 2023-07-04 12:45:08 pgsql: Remove incidental md5() function uses from several tests
Previous Message Peter Eisentraut 2023-07-04 09:42:07 Re: pgsql: ci: Change macOS builds from Intel to ARM.