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

From: "David Wilson" <david(dot)t(dot)wilson(at)gmail(dot)com>
To: "David Lambert" <davidl(at)dmisoft(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Determining offsets to jump to grab a group of records
Date: 2008-06-11 22:29:18
Message-ID: e7f9235d0806111529p28e4dd47x706b4ae37858695a@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Wed, Jun 11, 2008 at 5:54 PM, David Lambert <davidl(at)dmisoft(dot)com> wrote:
> I am trying to find a way to figure out what offset I would have to use in a
> SELECT with LIMIT and OFFSET clauses to get a grouping of records. For
> example:
>
> Consider a table full of first names. I want to be able to find the first
> offset where the name is "DAVID". (We'll say that it is the 1009th row in
> the resulting select) This way I could perform the following:
>
> SELECT name FROM nametable LIMIT 25 OFFSET 1009;
>

This isn't an answer to your direct question, but it seems to me as if
you've already decided on a solution (figuring out an offset) that's
non-optimal. If you're using offsets at all, you must have a distinct
sort ordering; if you have that, you should be able to accomplish the
same thing with a where clause instead of an offset. Is there a
particular reason why this doesn't work for you?

Perhaps the better question is "what are you trying to do with this?"
There may be a higher level solution that can be given.

--
- David T. Wilson
david(dot)t(dot)wilson(at)gmail(dot)com

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2008-06-11 22:34:09 Re: Unable to dump database using pg_dump
Previous Message David Lambert 2008-06-11 21:54:06 Determining offsets to jump to grab a group of records