Search Postgresql Archives

Re: Determining offsets to jump to grab a group of records

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

 



Scott Marlowe wrote:
Yes there is.  Use an indexed id field of some kind.

select * from table where idfield between 0 and 100;
select * from table where idfield between 1000000 and 1000100;

Will both be equally fast.  Offset / limit syntax requires the db to
materialize <offset>+<limit> rows for the query.  between and an id
does not.

An ID would work fine if you could always guarantee that you were ordering by the id. If not then the ID fields would be in non sequential order which would throw off the between above and give you incorrect data.

We need something that would be independent from the ordering that way a user could order it by first name, last name, brother's wife's maiden name, etc. and it would still work correctly.

Are there any other ways to accomplish this?  Thanks.

David Lambert



[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