Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

ORDER BY clause and Composit index

ShackirMar 4 2014 — edited Mar 10 2014

Hi all,


When oracle utilize index in ORDER BY Clause.


I've a table with UNIQUE KEY on two columns. Lets say TB_M_TEST1(col1 varchar2(10),col2 varchar2(10),col3 varchar2(10)).

and created unique key IX_UK_TEST1 on col1 and col2. and another index IX_MK_TEST_COL2 on col2 (is non-unique index).


now iam querying on the above table as follows select * from TB_M_TEST1 order by Col1, Col2. when i am checking the EXPLAIN PLAN, i found that the query is not utilizing the index.

And when i am querying like Select * from TB_M_TEST1  order by Col2, found that it is using INDEX


Question is that why first query is not using index where second query is using. And all answeres are really appreciated.

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 7 2014
Added on Mar 4 2014
22 comments
1,048 views