Re: how to make this database / query faster - Mailing list pgsql-general

From Richard Broersma
Subject Re: how to make this database / query faster
Date
Msg-id 396486430803151645m4c5f00a8r47f8829d5537c3c@mail.gmail.com
Whole thread Raw
In response to Re: how to make this database / query faster  (mark <markkicks@gmail.com>)
Responses Re: how to make this database / query faster  (brian <brian@zijn-digital.com>)
List pgsql-general
On Sat, Mar 15, 2008 at 4:41 PM, mark <markkicks@gmail.com> wrote:
On Sat, Mar 15, 2008 at 4:37 PM, Richard Broersma <richard.broersma@gmail.com> wrote:
On Sat, Mar 15, 2008 at 4:21 PM, mark <markkicks@gmail.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.

pgsql-general by date:

Previous
From: mark
Date:
Subject: Re: how to make this database / query faster
Next
From: brian
Date:
Subject: Re: how to make this database / query faster