Re: [PERFORM] Efficiently merging and sorting collections of sorted rows

2017-06-28 Thread Merlin Moncure
On Fri, Jun 23, 2017 at 6:33 PM, Tom Lane wrote: > Clint Miller writes: >> That's a good plan because it's not doing a quick sort. Instead, it's just >> reading the sort order off of the index, which is exactly what I want. (I >> had to disable enable_sort because I didn't have enough rows of tes

Re: [PERFORM] Efficiently merging and sorting collections of sorted rows

2017-06-23 Thread Tom Lane
Clint Miller writes: > That's a good plan because it's not doing a quick sort. Instead, it's just > reading the sort order off of the index, which is exactly what I want. (I > had to disable enable_sort because I didn't have enough rows of test data > in the table to get Postgres to use the index.

Re: [PERFORM] Efficiently merging and sorting collections of sorted rows

2017-06-23 Thread Peter Geoghegan
On Fri, Jun 23, 2017 at 3:58 PM, Clint Miller wrote: > Here, it's loading the full result set into memory and doing a quick sort. > (I think that's what it's doing, at least. If that's not the case, let me > know.) That's not good. It's not sorting stuff that doesn't need to be read into memory i

[PERFORM] Efficiently merging and sorting collections of sorted rows

2017-06-23 Thread Clint Miller
Let's say I have the following table and index: create table foo(s text, i integer); create index foo_idx on foo (s, i); If I run the following commands: start transaction; set local enable_sort = off; explain analyze select * from foo where s = 'a' order by i; end; I get the following query pl