Link to home
Start Free TrialLog in
Avatar of Monica2003
Monica2003

asked on

Create index on "order by" parameter?

Hi,

I know that you should create indexes on the "where" parameters, but I was wondering if you should create indexes on the "order by" paramters.  For example, in the query below, should I create an index on the "score" field?

select * from table where intl='us' and level='2' order by score;

Thanks for your help!
Avatar of Aneesh
Aneesh
Flag of Canada image

if this query is called so many times in an hour, then , creating the index is not a bad option. You should not that, indexes wont always improves performance, it can only improves the perfromance during the retrieval operation
Avatar of nitinmehta
nitinmehta

well, it will certainly help, otherwise the tree traversal (or the cost in short) for sorting will be much more.
Avatar of Monica2003

ASKER

Should I create a composite index(intl, level, score) or two indexes: index(intl, level) and index(score)?  Thanks!
ASKER CERTIFIED SOLUTION
Avatar of Lowfatspread
Lowfatspread
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I agree with Lowfatspread that the composite index will give the best performance