Re: [SQL] Changed to: how to solve the get next 100 records problem

2005-05-18 Thread PFC
The only strange thing is that without the 3rd order by, the order is wrong. I didn't expect it because each select is created ordered. Is it expected that UNION mixes it all up? (using postgre 7.4.1) That's because UNION removes duplicates, which it will probably doing using a hash (EXPLAI

Re: [SQL] Changed to: how to solve the get next 100 records problem

2005-05-18 Thread Ragnar Hafstaư
On Wed, 2005-05-18 at 12:42 -0300, Alain wrote: > I found something that is both fast and simple (program side): > ... > subsequent selects are > (select ... from tab WHERE skey=skey_last AND pkey>pkey_last > ORDER BY skey,pkey LIMIT 100) > UNION > (select ... from tab WHERE s

[SQL] Changed to: how to solve the get next 100 records problem

2005-05-18 Thread Alain
Hi Ragnar (and others), I found something that is both fast and simple (program side): Allways assuming that: pkey is a primary key and skey is a sort key, and there exists an index on (skey,pkey) first select is select ... from tab ORDER by skey,pkey LIMIT 100; subsequent selects are (select ... f