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]

 



On Wed, Jun 11, 2008 at 5:54 PM, David Lambert <davidl@xxxxxxxxxxx> 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.t.wilson@xxxxxxxxx


[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