Re: Determining offsets to jump to grab a group of records - Mailing list pgsql-general

From David Lambert
Subject Re: Determining offsets to jump to grab a group of records
Date
Msg-id g2reh2$2b7v$1@news.hub.org
Whole thread Raw
In response to Re: Determining offsets to jump to grab a group of records  ("Scott Marlowe" <scott.marlowe@gmail.com>)
List pgsql-general
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


pgsql-general by date:

Previous
From: Zoltan Boszormenyi
Date:
Subject: Re: Heavily fragmented table and index data in 8.0.3
Next
From: Andrew Sullivan
Date:
Subject: Re: Heavily fragmented table and index data in 8.0.3