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

From: David Lambert <davidl(at)dmisoft(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Determining offsets to jump to grab a group of records
Date: 2008-06-12 15:14:03
Message-ID: g2reh2$2b7v$1@news.hub.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2008-06-12 15:21:15 Re: Heavily fragmented table and index data in 8.0.3
Previous Message Tom Lane 2008-06-12 15:05:46 Re: Unable to dump database using pg_dump