Index Skip Key processing can be used when grouping with the keyed sequence implementation algorithm which uses an existing index. It is a specialized version of ordered grouping that processes very few records in each group rather than all records in each group.
The index skip key processing algorithm:
This will improve performance by potentially not processing all index key values for a group.
Index skip key processing can be used:
CREATE INDEX IX1 ON EMPLOYEE (SALARY DESC) DECLARE C1 CURSOR FOR SELECT MAX(SALARY) FROM EMPLOYEE;
The query optimizer will chose to use the index IX1. The SLIC runtime code will scan the index until it finds the first non-null value for SALARY. Assuming that SALARY is not null, the runtime code will position to the first index key and return that key value as the MAX of salary. No more index keys will be processed.
CREATE INDEX IX2 ON EMPLOYEE (DEPT, JOB,SALARY) DECLARE C1 CURSOR FOR SELECT DEPT, MIN(SALARY) FROM EMPLOYEE WHERE JOB='CLERK' GROUP BY DEPT
The query optimizer will chose to use Index IX2. The database manager will position to the first group for DEPT where JOB equals 'CLERK' and will return the SALARY. The code will then skip to the next DEPT group where JOB equals 'CLERK'.
Example 1, using SQL:
CREATE INDEX IX1 ON DEPARTMENT(DEPTNAME) CREATE INDEX IX2 ON EMPLOYEE(WORKDEPT, SALARY) DECLARE C1 CURSOR FOR SELECT DEPTNAME, MIN(SALARY) FROM DEPARTMENT, EMPLOYEE WHERE DEPARTMENT.DEPTNO=EMPLOYEE.WORKDEPT GROUP BY DEPARTMENT.DEPTNO;