select single entry and its neighbours using direct-acess to index?

From: peter pilsl <pilsl(at)goldfisch(dot)at>
To: PostgreSQL List <pgsql-general(at)postgresql(dot)org>
Subject: select single entry and its neighbours using direct-acess to index?
Date: 2004-12-06 09:05:16
Message-ID: 41B420CC.608@goldfisch.at
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(at)goldfisch(dot)at

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Postgres Learner 2004-12-06 09:28:46 8.0 vs. 7.4 benchmarks
Previous Message Julian Scarfe 2004-12-06 08:48:04 Re: Index bloat in 7.2