Re: read backwards?

From: Alexandr I. Alesinsky <al_at_investor.kharkov.ua>
Date: 1995/08/19
Message-ID: <ADWdUDmGXR_at_investor.kharkov.ua>#1/1


>
>We have a database with appoximately 500,000 rows. One query allows users
>to bring up a list of names so that they can narrow down to a specific
>data record. When the list is up, we want them to have the ability to
>page forward and backward. The forward works fine, however the backward query
>using a 'where name < first_displayed_name' type of query goes back to
>the begining of the table and basically reads 1,000s of rows.
>
>Is there a way to read backwards from a certian point and return say the
>next 25 names before a specific key and not have ORacle start from the
>begining of the table?
>
>PS. Sorry if I'm unclear on this, it's easy to visualize, tought to explain!
>
>

The answer is YES, if you have Oracle 7.x.

You must use INDEX_DESC hint in your SELECT, e.g.

SELECT /*+INDEX_DESC X XINDEX*/ x.x
 FROM x
 WHERE x<desired_key and rownum<=25;

It is assumed that table X is indexed on column x;

Alexander Alesinsky,
JSV Investor,
Kharkov, Ukraine Received on Sat Aug 19 1995 - 00:00:00 CEST

Original text of this message