The best solution : Use Index Hint ( you must already create the index on the column you want to sort )
Example: SELECT /*+ INDEX_ASC (Your_table your_index) */
col1 , ...
FROM department
where rownum <= 5
Example: SELECT /*+ INDEX_ASC (Your_table your_index) */
col1 , ...
FROM department
where rownum <= 5
write a PL/SQL block , define a cursor inside and loop it and fetch the first 5 records . It should be very fast .
col1 , ...
FROM department
where rownum <= 5
请问*+ INDEX_ASC (Your_table your_index) */ 是什么意思啊
先create a index
create index id_indx on dir_hotel(id);
然后
select /*+index_asc(dir_hotel id_indx)*/ * from dir_hotel where rownum<5