select single entry and its neighbours using direct-acess to index? - Mailing list pgsql-general

From peter pilsl
Subject select single entry and its neighbours using direct-acess to index?
Date
Msg-id 41B420CC.608@goldfisch.at
Whole thread Raw
Responses Re: select single entry and its neighbours using direct-acess to index?  (Pierre-Frédéric Caillaud<lists@boutiquenumerique.com>)
List pgsql-general
Is there an easy solution for this?

I'd like to select a single entry from a table and the entries that
would be previous and next given to a certain order.

like

select id from mytable where id=45 order by name,name2;

and then I'd like to select the two entries that would come before and
after according to the order "name,name2";
id is not ordered, but there is an index on  (name,name2) so the needed
infomation about previous, next should be stored somewhere in this index.

My current solution is to read all the data without the WHERE-clause and
then fetch the needed ones, which is quite time-demanding.

thnx,
peter



--
mag. peter pilsl
goldfisch.at
IT-management
tel +43 699 1 3574035
fax +43 699 4 3574035
pilsl@goldfisch.at

pgsql-general by date:

Previous
From: "Julian Scarfe"
Date:
Subject: Re: Index bloat in 7.2
Next
From: dom@happygiraffe.net (Dominic Mitchell)
Date:
Subject: Re: When to encrypt