Q

Using an index with the ORDER BY clause

I have a table with about 500,000 records, and I want to select from this table filtering records by col1, col2 and col3. Also, I want to order the results by three other columns: col4, col5, col6. I have tried to optimize the query using an index on col4, col5 and col6, but when I change the column order in the order by clause or the direction (acending or descending), the index is not used. My question it is what kind of index should I use for the order by clause? The database version it is Oracle 9i.
The index should match your order by clause, as you have seen. If you want to order by col4, col5, col6, create the index with the columns in the same order.
This was first published in June 2005

Dig deeper on Oracle database performance problems and tuning

Pro+

Features

Enjoy the benefits of Pro+ membership, learn more and join.

Have a question for an expert?

Please add a title for your question

Get answers from a TechTarget expert on whatever's puzzling you.

You will be able to add details on the next page.

0 comments

Oldest 

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

-ADS BY GOOGLE

SearchDataManagement

SearchBusinessAnalytics

SearchSAP

SearchSQLServer

TheServerSide

SearchDataCenter

SearchContentManagement

SearchFinancialApplications

Close