Re: Reverse collations (initially for making keyset pagination cover more cases)

2019-11-18 Thread Andrew Gierth
> "Tom" == Tom Lane writes: >> Well, one obvious completely general method is to teach the planner >> (somehow) to spot conditions of the form >> (a > $1 OR (a = $1 AND b > $2) OR (a = $1 AND b = $2 AND c > $3) ...) >> etc. and make them indexable if the sense of the > or < operator at >

Re: Reverse collations (initially for making keyset pagination cover more cases)

2019-11-18 Thread Tom Lane
Andrew Gierth writes: > "Tom" == Tom Lane writes: > Tom> Lastly, your proposed use-case has some attraction, but this > Tom> proposal only supports it if the column you need to be differently > Tom> sorted is textual. What if the sort columns are all numerics and > Tom> timestamps? > There a

Re: Reverse collations (initially for making keyset pagination cover more cases)

2019-11-17 Thread David Fetter
On Sun, Nov 17, 2019 at 11:23:23PM +, Andrew Gierth wrote: > > "David" == David Fetter writes: > > First, in testing the patch I found there were indeed some missing > cases: the sortsupport version of the comparator needs to be fixed too. > I attach a draft addition to your patch, you sh

Re: Reverse collations (initially for making keyset pagination cover more cases)

2019-11-17 Thread Andrew Gierth
> "David" == David Fetter writes: First, in testing the patch I found there were indeed some missing cases: the sortsupport version of the comparator needs to be fixed too. I attach a draft addition to your patch, you should probably look at adding test cases that need this to work. David>

Re: Reverse collations (initially for making keyset pagination cover more cases)

2019-11-17 Thread David Fetter
On Sun, Nov 17, 2019 at 02:30:35PM -0500, Tom Lane wrote: > David Fetter writes: > > Please find attached a patch for $Subject. > > I think there's a reason why this hasn't been proposed before. > > Back before we had full support of ASC/DESC index sort order, there was > interest in having reve

Re: Reverse collations (initially for making keyset pagination cover more cases)

2019-11-17 Thread Andrew Gierth
> "Tom" == Tom Lane writes: Tom> Lastly, your proposed use-case has some attraction, but this Tom> proposal only supports it if the column you need to be differently Tom> sorted is textual. What if the sort columns are all numerics and Tom> timestamps? There are already trivial ways to r

Re: Reverse collations (initially for making keyset pagination cover more cases)

2019-11-17 Thread Tom Lane
David Fetter writes: > Please find attached a patch for $Subject. I think there's a reason why this hasn't been proposed before. Back before we had full support of ASC/DESC index sort order, there was interest in having reverse-sort operator classes, and there are bits and pieces still in the co

Reverse collations (initially for making keyset pagination cover more cases)

2019-11-17 Thread David Fetter
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