The same logic that is applied to removing ordering columns can also be used to add additional ordering columns to the query. This is only done when you are trying to determine if an index can be used to implement the ordering.
The following example illustrates a query where the optimizer could add an additional ordering column:
CREATE INDEX X1 ON EMPLOYEE (EMPNO, LASTNAME, WORKDEPT)
DECLARE DEPTEMP CURSOR FOR
SELECT LASTNAME, WORKDEPT
FROM CORPDATA.EMPLOYEE
WHERE EMPNO = '000190'
ORDER BY LASTNAME, WORKDEPT
For this query request, the optimizer implicitly adds EMPNO as an additional ordering column when considering index X1 for the query.
For more information, see Database Performance and Query Optimization in the
Information Center .