Hi,
I am trouble shooting a performance problem.
I run a similar query against two different tables, both have a compound primary key and in both this compound key is indexed.
The columns that are the compound primary key and the index are:
ClassId and Index.
The 1st Query is
SELECT CLASSID, INDEX, HEIGHT, WEIGHT, AGE FROM PERSON
WHERE CLASSID = 5 ORDER BY CLASSID, INDEX;
The 2nd Query is against EMPLOYEE and is
SELECT CLASSID, INDEX, HEIGHT, WEIGHT, AGE FROM EMPLOYEE
WHERE CLASSID = 6 ORDER BY CLASSID, INDEX;;
When I look at the explain plans, one query uses the index the other does not.
My question is if a index is a combination of columns, when is that index actually used?
Is it when
-both columns are specified in the where clause?
-both columns are specified in the orderBy clause?
-when one of the two columns is specifed in the where clause?
-when one of the two columns is specifed in the order by clause?
or
-all the time as it is also the primary key?
Any help greatly appreciated!