Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> find nearest, using index in oracle 8.1.5.0.5

find nearest, using index in oracle 8.1.5.0.5

From: Evgeny Sorokin <sor1_at_aha.ru>
Date: Mon, 21 Feb 2000 01:40:17 +0300
Message-ID: <88pq0t$25pi$1@gavrilo.mtu.ru>


Hello!
I found, thet queries
select min(f1) from t1 where f1>:a

               and
select max(f1) from t1 where f1<:a
(where t1 indexed on f1) runs SLOWLY!!!
"explain plan" shows "fast full index scan". If I use /*+ RULE */, then
"range scan", but also slowly even more.
Then I found FAST queries:
select f1 from (
  select f1 from t1 where f1>:a order by f1)   where rownum=1

         and
select f1 from (
  select f1 from t1 where f1<:a order by f1 desc)   where rownum=1

I was so happy, but then I found, that such queries can not be inserted into stored procedure

Oracle said, that it can not understand "order by". May be I can ommit "order by", but it is NOT GOOD practise, because in other versions it can't work with guarantee.
I don't want to useŘ DBMS_SQL, may be somebody can advise something better? Evgeny Sorokin Received on Sun Feb 20 2000 - 16:40:17 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US