Home Tips and Tricks ABAP Reports Performance guidelines on Indices
|
|
|
|
Performance guidelines on Indices |
|
|
|
|
Written by Anon.
|
|
Tuesday, 13 March 2007 |
An index will not be used if the following operators are present on the indexed fields in your WHERE clause:
- NOT or NE or <>
- LIKE ‘%pattern’
- IS NULL
- IS NOT NULL
- NOT IN
Specify field values without gaps. In other words, if a table has field1, field2, and field3 as the index, your where clause should not have only field1 and field3. Leaving out field2 causes the leading index for the only the first field to be used. If the where clause contained field1 and field2 but not field3, the index would include field1 and field2.
Example: A database table dbtable1 has an index on field1, field2, field3. Good SELECT fieldn INTO v_fieldn FROM dbtable1 WHERE field1 = value1 AND field2 = value2 AND field3 = value3 The database can use index on field1, field2 and field3.
Bad SELECT fieldn INTO v_fieldn FROM dbtable1 WHERE field1 = value1 AND field3 = value3 The database can only use index on field1. Good
You can use an index efficiently by using the below examples.
Example 1: Provide bound values to complete the index. SELECT WERKS MATNR J_3ASTAT AUFNR INTO TABLE T_BDBFROM J_3ABDBS WHERE WERKS IN O_WERKS AND MATNR IN O_MATNR AND J_3ASTAT = C_FIXED AND “C_FIXED = F AUFNR IN O_AUFNR.
Example 2: Use subquery on a check table to complete the index SELECT BUKRS BELNR GJAHR BLART INTO TABLE T_BKPF FROM BKPF WHERE BUKRS IN ( SELECT BUKRS FROM T001 ) AND BELNR IN O_BELNR AND GJAHR = P_GJAHR.
Related Items:
|
|
|
|