Reverse collations (initially for making keyset pagination covermore cases) - Mailing list pgsql-hackers

From David Fetter
Subject Reverse collations (initially for making keyset pagination covermore cases)
Date
Msg-id 20191117182408.GA13566@fetter.org
Whole thread Raw
Responses Re: Reverse collations (initially for making keyset pagination cover more cases)  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
Folks,

Please find attached a patch for $Subject.

Motivation:

When people are doing keyset pagination, the simple cases redound to
adding a WHERE that looks like

    (a, b, c) > (most_recent_a, most_recent_b, most_recent_c)

which corresponds to an ORDER BY clause that looks like

    ORDER BY a, b, c

The fun starts when there are mixes of ASC and DESC in the ORDER BY
clause. Reverse collations make this simpler by inverting the meaning
of > (or similar), which makes the rowtypes still sortable in a new
dictionary order, so the pagination would look like:


    (a, b, c) > (most_recent_a, most_recent_b COLLATE "C_backwards", most_recent_c)

with an ORDER BY like:

    ORDER BY a, b DESC, c

What say?

Best,
David.
-- 
David Fetter <david(at)fetter(dot)org> http://fetter.org/
Phone: +1 415 235 3778

Remember to vote!
Consider donating to Postgres: http://www.postgresql.org/about/donate

Attachment

pgsql-hackers by date:

Previous
From: Alexander Korotkov
Date:
Subject: Re: Connections hang indefinitely while taking a gin index's LWLockbuffer_content lock(PG10.7)
Next
From: Tom Lane
Date:
Subject: Re: Reverse collations (initially for making keyset pagination cover more cases)