Add sortsupport to money_ops, pg_lsn_ops and xid8_ops

Started by Kirill Reshke16 days ago7 messageshackers
Jump to latest
#1Kirill Reshke
reshkekirill@gmail.com

While benchmarking the effects of the recent (41467b1d88) GIN speedup,
I noticed that btree opclasses for money/pg_lsn/xid8 have no
sortsupport

I think this is a clear miss, so PFA

This can speedup CREATE INDEX on money type in ~20%, try

CREATE TABLE m AS SELECT (hashint8(i)::numeric/100)::money FROM
generate_series(1,1000000) i; create index on m (money ); -- 339ms
base vs 260ms patched for me

Also, ORDER BY col would also be faster. Maybe merge join will get
benefit - i didn't measure this

--
Best regards,
Kirill Reshke

Attachments:

t254590_1
pg_lsn_money_xid8.diffapplication/octet-stream; name=pg_lsn_money_xid8.diffDownload+7-0
#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Kirill Reshke (#1)
Re: Add sortsupport to money_ops, pg_lsn_ops and xid8_ops

Kirill Reshke <reshkekirill@gmail.com> writes:

While benchmarking the effects of the recent (41467b1d88) GIN speedup,
I noticed that btree opclasses for money/pg_lsn/xid8 have no
sortsupport

Is it really worth the development and ongoing maintenance costs
to carry such code? I doubt many users are doing large sorts on
columns of these data types.

regards, tom lane

#3Andrey Borodin
amborodin@acm.org
In reply to: Tom Lane (#2)
Re: Add sortsupport to money_ops, pg_lsn_ops and xid8_ops

On 6 Nov 2026, at 21:24, Tom Lane <tgl@sss.pgh.pa.us> wrote:

Is it really worth the development and ongoing maintenance costs
to carry such code? I doubt many users are doing large sorts on
columns of these data types.

I've definitely seen people sort moneys.
But IMO, the patch is more about feature alignment than practical benefit.

Best regards, Andrey Borodin.

#4Michael Paquier
michael@paquier.xyz
In reply to: Andrey Borodin (#3)
Re: Add sortsupport to money_ops, pg_lsn_ops and xid8_ops

On Fri, Nov 06, 2026 at 09:53:05PM +0500, Andrey Borodin wrote:

But IMO, the patch is more about feature alignment than practical benefit.

I could get behind the money part. The two others? Let me doubt.
--
Michael

#5Kirill Reshke
reshkekirill@gmail.com
In reply to: Tom Lane (#2)
Re: Add sortsupport to money_ops, pg_lsn_ops and xid8_ops

On Fri, 6 Nov 2026 at 21:24, Tom Lane <tgl@sss.pgh.pa.us> wrote:

Kirill Reshke <reshkekirill@gmail.com> writes:

While benchmarking the effects of the recent (41467b1d88) GIN speedup,
I noticed that btree opclasses for money/pg_lsn/xid8 have no
sortsupport

Is it really worth the development and ongoing maintenance costs
to carry such code? I doubt many users are doing large sorts on
columns of these data types.

Hi!
Thanks for looking.
It didn't occur to me that this would require any maintenance cost.
Saying that, I think money type is something people use

--
Best regards,
Kirill Reshke

#6David Rowley
dgrowleyml@gmail.com
In reply to: Kirill Reshke (#5)
Re: Add sortsupport to money_ops, pg_lsn_ops and xid8_ops

On Mon, 9 Nov 2026 at 17:10, Kirill Reshke <reshkekirill@gmail.com> wrote:

It didn't occur to me that this would require any maintenance cost.
Saying that, I think money type is something people use

Any basis for those thoughts? I've only ever seen its usage
discouraged and even a short discussion [1]/messages/by-id/ZXgh74Ykj3iWvXKr@paquier.xyz on how we might remove it
one day.

Perhaps we should make pg_upgrade start kicking out warnings in v20
and then remove it in v25... Or reconsider that if we receive too many
complaints.

David

[1]: /messages/by-id/ZXgh74Ykj3iWvXKr@paquier.xyz

#7Andreas Karlsson
andreas.karlsson@percona.com
In reply to: David Rowley (#6)
Re: Add sortsupport to money_ops, pg_lsn_ops and xid8_ops

On 11/9/26 08:53, David Rowley wrote:

On Mon, 9 Nov 2026 at 17:10, Kirill Reshke <reshkekirill@gmail.com> wrote:

It didn't occur to me that this would require any maintenance cost.
Saying that, I think money type is something people use

Any basis for those thoughts? I've only ever seen its usage
discouraged and even a short discussion [1] on how we might remove it
one day.

Perhaps we should make pg_upgrade start kicking out warnings in v20
and then remove it in v25... Or reconsider that if we receive too many
complaints.

Yeah, I think we should deprecate the money type. It is weird and
confusing to any user and the name makes some people think that it is
useful for storing money when it is generally not. I would rather that
we work on deprecating it over improving it. Maybe it can be turned into
an extension for the people who want it, but the issue is pg_upgrade and
type type oid.

--
Andreas Karlsson
Percona