From: | mark <markkicks(at)gmail(dot)com> |
---|---|
To: | brian <brian(at)zijn-digital(dot)com> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: how to make this database / query faster |
Date: | 2008-03-16 00:28:38 |
Message-ID: | 82fa9e310803151728i23e39db8v820a000cb01e4883@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Sat, Mar 15, 2008 at 5:04 PM, brian <brian(at)zijn-digital(dot)com> wrote:
> Richard Broersma wrote:
> > On Sat, Mar 15, 2008 at 4:41 PM, mark <markkicks(at)gmail(dot)com> wrote:
> >
> >> On Sat, Mar 15, 2008 at 4:37 PM, Richard Broersma <
> >> richard(dot)broersma(at)gmail(dot)com> wrote:
> >>
> >>> On Sat, Mar 15, 2008 at 4:21 PM, mark <markkicks(at)gmail(dot)com> 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 previous scan:
> >>> SELECT *
> >>> FROM Users
> >>> WHERE session_key IS NOT NULL
> >>> AND id > your_last_id
> >>> LIMIT 300;
> >>>
> >> will this ensure that no row is repeated when i itereate over the
> table?
> >> what are the rows ordered by?
> >> thanks
> >>
> >
> > Ya, sorry I forgot to include the order by.
> >
> > SELECT *
> > FROM Users
> > WHERE session_key IS NOT NULL
> > AND id > your_last_id
> > ORDER BY id
> > LIMIT 300;
> >
> > Yes there will not be any repeated rows sence you are using a order set
> > that who's ID are greated than the last set.
> >
>
> 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 session_key also
but i dont have a session key combined on both. should i do that?
From | Date | Subject | |
---|---|---|---|
Next Message | brian | 2008-03-16 00:30:36 | Re: how to make this database / query faster |
Previous Message | brian | 2008-03-16 00:04:07 | Re: how to make this database / query faster |