RBO secret #2

If all the columns belonging to a certain index are listed in the WHERE clause, then the index will have priority over the other (in the case where the appeal was only part of the column).

For example:

SELECT col1, ...
FROM emp
WHERE emp_name = 'Gurry'
AND emp_no - 127
AND dept_no = 12;
Indexl (emp_name)
Index2 (emp_no, dept_no, cost_center)

In the example above, will be used Index1 because the WHERE clause contains all of its columns, and this is not the case Index2.

No comments: