Re: Let an ordering index scan hand its ORDER BY value to the target list

From: Greg Burd <greg(at)burd(dot)me>
To: pgsql-hackers(at)lists(dot)postgresql(dot)org
Cc: Oleg Bartunov <obartunov(at)postgrespro(dot)ru>, Matthias van de Meent <boekewurm+postgres(at)gmail(dot)com>, Heikki Linnakangas <hlinnaka(at)iki(dot)fi>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Chris Cleveland <ccleveland(at)dieselpoint(dot)com>
Subject: Re: Let an ordering index scan hand its ORDER BY value to the target list
Date: 2026-12-03 17:56:05
Message-ID: 179631843082.2709378.6489341246088814212@burd.me
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Sun, Nov 22, 2026 at 4:35 PM Greg Burd <greg(at)burd(dot)me> wrote:

Hi all,

For anyone just now joining this thread, the series lets an ordering
index scan hand the ORDER BY value it already computed to the plan's
target list, instead of making an upper node recompute it. This came up
when working on a bm25 index (pg_fts) and I would imagine it impacts
other similar indexes out there.

The big change in this version, I split 0001 out [1]. In my earlier
message 0001 fixed a pre-existing inexactness in the point-to-box
distance operator, which I stumbled onto while debugging this series'
box tests.

While interesting and useful for testing it isn't necessary or related
to these changes at all. This series no longer depends on those
changes. The box test for the feature is still here, as a separate file
that is not in the regression schedule (the attachment with the .nocfbot
suffix, so cfbot leaves it alone). It cannot pass without the distance
fix [1] and the box_ops branch in gistcanreturnorderby() and
spgcanreturnorderby(). When the distance patch lands, add box_ops back
to those two functions, fold the file's blocks into gist.sql beside the
point_ops cases, and drop the file.

v18 attached, rebased onto f68727292ae. I think the series is ready for
serious consideration should any committer have the time and interest.

best.

-greg

[1] https://postgr.es/m/179631667918.2040837.8991557170201867655@burd.me

Attachment Content-Type Size
v18-0003-Let-an-ordering-index-scan-below-a-join-emit-its.patch application/octet-stream 20.2 KB
v18-0005-Let-an-index-only-scan-win-on-the-index-expressi.patch application/octet-stream 14.4 KB
v18-0008-box-test.patch.nocfbot application/octet-stream 7.9 KB
v18-0007-Carry-index-computed-values-through-outer-joins-.patch application/octet-stream 54.4 KB
v18-0001-Let-an-ordering-index-scan-hand-its-ORDER-BY-val.patch application/octet-stream 61.8 KB
v18-0002-Don-t-charge-an-ordering-index-scan-for-ORDER-BY.patch application/octet-stream 23.5 KB
v18-0004-Don-t-charge-an-index-only-scan-for-index-expres.patch application/octet-stream 8.4 KB
v18-0006-Carry-index-computed-values-up-through-joins-and.patch application/octet-stream 87.4 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Previous Message Matheus Alcantara 2026-12-03 17:49:18 Re: executor startup doesn't skip sub-partitions of a pruned partition