Re: [GENERAL] how to make this database / query faster

2008-03-16 Thread Richard Broersma
On Sun, Mar 16, 2008 at 9:47 AM, Martin Gainty <[EMAIL PROTECTED]> wrote: > My understanding is that Partial index is implemented for low cardinality > scenarios ('Y'/'N') ('T'/'F') (null/not null) ? > http://en.wikipedia.org/wiki/Partial_index > Low cardinality can apply for more than just bool

Re: [GENERAL] how to make this database / query faster

2008-03-16 Thread Martin Gainty
n null records would not apply ? Martin- - Original Message - From: Richard Broersma To: brian Cc: pgsql-general@postgresql.org Sent: Sunday, March 16, 2008 10:25 AM Subject: Re: [GENERAL] how to make this database / query faster On Sat, Mar 15, 2008 at 5:04 PM, brian &l

Re: [GENERAL] how to make this database / query faster

2008-03-16 Thread Richard Broersma
On Sat, Mar 15, 2008 at 5:04 PM, brian <[EMAIL PROTECTED]> wrote: > As there's an index on id would it be faster to transpose the WHERE > conditions? > > WHERE id > your_last_id > AND session_key IS NOT NULL > > I can't remember if the order of WHERE is significant. > I don't think that the order

Re: [GENERAL] how to make this database / query faster

2008-03-16 Thread Volkan YAZICI
On Sat, 15 Mar 2008, mark <[EMAIL PROTECTED]> writes: > select * from users where session_key is not Null order by id offset OFFSET > limit 300 > > i want to go through the whole table... it gets really slow like > greater than 5 minutes when the OFFSET is over 500,000.. Did you try your chance w

Re: [GENERAL] how to make this database / query faster

2008-03-15 Thread brian
mark wrote: On Sat, Mar 15, 2008 at 5:04 PM, brian <[EMAIL PROTECTED]> wrote: As there's an index on id would it be faster to transpose the WHERE conditions? WHERE id > your_last_id AND session_key IS NOT NULL I can't remember if the order of WHERE is significant. brian, i have an index on

Re: [GENERAL] how to make this database / query faster

2008-03-15 Thread mark
On Sat, Mar 15, 2008 at 5:04 PM, brian <[EMAIL PROTECTED]> wrote: > Richard Broersma wrote: > > On Sat, Mar 15, 2008 at 4:41 PM, mark <[EMAIL PROTECTED]> wrote: > > > >> On Sat, Mar 15, 2008 at 4:37 PM, Richard Broersma < > >> [EMAIL PROTECTED]> wrote: > >> > >>> On Sat, Mar 15, 2008 at 4:21 PM,

Re: [GENERAL] how to make this database / query faster

2008-03-15 Thread brian
Richard Broersma wrote: On Sat, Mar 15, 2008 at 4:41 PM, mark <[EMAIL PROTECTED]> wrote: On Sat, Mar 15, 2008 at 4:37 PM, Richard Broersma < [EMAIL PROTECTED]> wrote: On Sat, Mar 15, 2008 at 4:21 PM, mark <[EMAIL PROTECTED]> wrote: select * from users where session_key is not Null order b

Re: [GENERAL] how to make this database / query faster

2008-03-15 Thread Richard Broersma
On Sat, Mar 15, 2008 at 4:41 PM, mark <[EMAIL PROTECTED]> wrote: > On Sat, Mar 15, 2008 at 4:37 PM, Richard Broersma < > [EMAIL PROTECTED]> wrote: > > > On Sat, Mar 15, 2008 at 4:21 PM, mark <[EMAIL PROTECTED]> wrote: > > > > > > > select * from users where session_key is not Null order by id off

Re: [GENERAL] how to make this database / query faster

2008-03-15 Thread mark
On Sat, Mar 15, 2008 at 4:37 PM, Richard Broersma < [EMAIL PROTECTED]> wrote: > On Sat, Mar 15, 2008 at 4:21 PM, mark <[EMAIL PROTECTED]> wrote: > > > > select * from users where session_key is not Null order by id offset > > OFFSET limit 300 > > > > One solution is to retain the last ID from the

Re: [GENERAL] how to make this database / query faster

2008-03-15 Thread Richard Broersma
On Sat, Mar 15, 2008 at 4:21 PM, mark <[EMAIL PROTECTED]> wrote: > select * from users where session_key is not Null order by id offset > OFFSET limit 300 > > OFFSET actually scans past all of the records that specify in the "OFFSET". So the bigger your offset the longer the scan will be. One s