CRITICAL
Rule Definition
SQL Queries that do not use table indexes are extremely dangerous for the application's performance.
Indeed, each execution of the query will result in a full table scan which is extremely time consuming especially if the table contains an extremely large amount of data (XXL table).
Remediation
Try to use indexed columns in WHERE clauses. If it is not possible, then create a secondary index for these columns.
Violation Code Sample
TABLE1 is indexed on (COL2, COL1) and TABLE2 on COL3. Both tables are XXL.
For the following statement :
Select O.COL1, O.COL2, O.COL2, 1, 0, 0, 1
From TABLE1 O, TABLE2 OT
Where O.COL3 = OT.COL3
And O.COL1 in (1, 2)
And OT.COL4 = 1;
TABLE2's index cover the statement.
TABLE1 is reported in violation.
Fixed Code Sample
TABLE1 is indexed on (COL2, COL1) and TABLE2 on COL3. Both tables are XXL.
For the following statement :
Select O.COL1, O.COL2, O.COL2, 1, 0, 0, 1
From TABLE1 O, TABLE2 OT
Where O.COL3 = OT.COL3
And O.COL1 in (1, 2)
And OT.COL4 = 1;
TABLE2's index cover the statement.
TABLE1 is reported in violation. The remediation is to add index on TABLE1 (COL3, COL1).
Reference
Enhancing the Quality of ABAP Development
Meijs - Krouwels - Heuvelmans - Sommen
SAP Press
ISBN 1-59229-030-2
Related Technologies
Technical Criterion
CWE-1067 - Excessive Execution of Sequential Searches of Data Resource
About CAST Appmarq
CAST Appmarq is by far the biggest repository of data about real IT systems. It's built on thousands of analyzed applications, made of 35 different technologies, by over 300 business organizations across major verticals. It provides IT Leaders with factual key analytics to let them know if their applications are on track.