Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> my problem with
Does anyone can explain this to me :
I have table "T1" with 300.000 rows, one index on field "F1"
and rows are not inserted in sequence order (F1 : first inserted "000002",
second inserted "000003", then "000008", "000001", "000004",... => I need
sort to have first 5 as result)
SELECT /*+FIRST_ROWS*/ * FROM t1 WHERE ROWNUM <= 50 ORDER BY f1
thoesn't work well, and
SELECT /*+FIRST_ROWS*/ * FROM ( SELECT * FROM t1 ORDER BY f1 ) WHERE ROWNUM
<= 50
work well but slow because this take full table scan.
This is my question :
Why when I use :
SELECT /*+FIRST_ROWS*/ * FROM t1 WHERE f1 IN)
(
SELECT f1 FROM t1 WHERE ROWNUM <= 50
and if I change that in
SELECT /*+FIRST_ROWS*/ * FROM t1 WHERE f1 IN)
(
SELECT f1 FROM t1 WHERE ROWNUM <= 50 MINUS SELECT f1 FROM t1 WHERE ROWNUM <= 0
![]() |
![]() |