Search Postgresql Archives

Re: how to make this database / query faster

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sat, Mar 15, 2008 at 4:21 PM, mark <markkicks@xxxxxxxxx> 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 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;

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux