Re: best way to retreive the next record in a multi column index - Mailing list pgsql-hackers

From Bruno Wolff III
Subject Re: best way to retreive the next record in a multi column index
Date
Msg-id 20030815201503.GA14932@wolff.to
Whole thread Raw
In response to best way to retreive the next record in a multi column index  ("Merlin Moncure" <merlin.moncure@rcsonline.com>)
List pgsql-hackers
On Fri, Aug 15, 2003 at 13:42:23 -0400, Merlin Moncure <merlin.moncure@rcsonline.com> wrote:
>  
> Example: 
> I have a table t with columns a, b, c.  I have values a1, b1, c1 for
> those columns and would like to know the next value in the table when
> ordered by a, b.  I have values a1, b1, and oid1 and would like to find
> the very next record in the table (essentially looking for the next
> record in the index).
>  
> I have two solutions: one with 'or' logic and one with 'and' logic.
> Note: if the index we are scanning has the unique constraint, the oid
> part of the logic (and the index) can be left out.
>  
How about something like the following:
select * from t
where  a >= a1 and b >= b1           order by a, b limit 1 offset 1;


pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: Bounds error in LockMethodInit().
Next
From: ohp@pyrenet.fr
Date:
Subject: Re: UnixWare on Current CVS: Success!