Re: Using Btree to Provide Sorting on Suffix Keys with LIMIT

2023-09-19 Thread Peter Geoghegan
On Fri, Jan 18, 2019 at 12:15 PM James Coleman wrote: > I'll attempt to describe a more real world scenario: suppose we have a > schema like: > > users(id serial primary key) > orders(id serial primary key, user_id integer, created_at timestamp) > > And wanted to find the most recent N orders for

Re: Using Btree to Provide Sorting on Suffix Keys with LIMIT

2019-01-18 Thread James Coleman
On Thu, Jan 10, 2019 at 6:52 PM Peter Geoghegan wrote: > > On Sat, Dec 29, 2018 at 6:50 PM David Rowley > wrote: > > > Areas of extension: (given index `(a, b, c)`) include `a = 1 and b in > > > (...) order by c` and `a in (...) and b = 1 order by c` (and further > > > similar derivations with in

Re: Using Btree to Provide Sorting on Suffix Keys with LIMIT

2019-01-10 Thread Peter Geoghegan
On Sat, Dec 29, 2018 at 6:50 PM David Rowley wrote: > > Areas of extension: (given index `(a, b, c)`) include `a = 1 and b in > > (...) order by c` and `a in (...) and b = 1 order by c` (and further > > similar derivations with increasing numbers of equality quals). > > I don't quite understand th

Re: Using Btree to Provide Sorting on Suffix Keys with LIMIT

2018-12-30 Thread James Coleman
On Sat, Dec 29, 2018 at 9:50 PM David Rowley wrote: > > On Sun, 30 Dec 2018 at 13:00, James Coleman wrote: > > Note that the index scan (or bitmap scan) nodes return all 1500 rows > > matching `bar_fk IN (1,2,3)`. After all rows are returned, that total > > set is ordered, and finally the LIMIT i

Re: Using Btree to Provide Sorting on Suffix Keys with LIMIT

2018-12-29 Thread David Rowley
On Sun, 30 Dec 2018 at 13:00, James Coleman wrote: > Note that the index scan (or bitmap scan) nodes return all 1500 rows > matching `bar_fk IN (1,2,3)`. After all rows are returned, that total > set is ordered, and finally the LIMIT is applied. While only 50 rows > were requested, 30x that were f