Avoid character string padding
Try to use the same data length when comparing a fixed-length character string column value to a host variable or constant value. DB2 Universal Database™ for iSeries™ does not use an index if the constant value or host variable is longer than the column length.
For example, EMPNO is CHAR(6) and DEPTNO is CHAR(3). For example, when using SQL, specify the following:
… WHERE EMPNO > '000300' AND DEPTNO < 'E20'instead of
… WHERE EMPNO > '000300 ' AND DEPTNO < 'E20 'When using the OPNQRYF command, specify:
... QRYSLT('EMPNO *GT "000300" *AND DEPTNO *LT "E20"')instead of... QRYSLT('EMPNO *GT "000300" *AND DEPTNO *LT "E20"')
Parent topic:
Coding for effective indexes