Rule Definition
Whenever a query with a WHERE clause does not use the first column of composite index (multiple column base index), the database engine will not use the composite index to retrieve the data, potentially leading to very poor performance.
Remediation
Depending on the context, the user has to evaluate if the fact that the composite index is not is leading to poor performance.
If the query does not use other indexes, the fact that the query does not use the first column of a composite index is most probably an error that needs to be fixed.
Violation Code Sample
The table T is defined the 4 following columns : A, B, C, D
The analyzed application has one artifact that contains the following query :
SELECT * FROM T WHERE B = 'X'
Example 1 :
Table T has the following index defined i1 on (A, B, C) columns.
The artifact will be part of the output of this metric to inform the user that i1 will not be used by the query processor engine.
Example 2 :
Table T has the following indexes defined i2 (B, C) and i3 (B).
The artifact will not be part of the output of this metric (first column (i3) or composite index( i2) is used).
Note artifact is part of the scope and is counted by the total procedure.
Example 3 :
Table T has the following indexes defined i1 (A, B, C), and i3 (B).
The artifact will be part of the output of this metric to inform the user that i1 will not be used by the database engine, even if the database engine uses the index i3.
Example 4 :
Table T has the following index defined i3 (B).
The artifact is ignored by this metric.
Related Technologies
PL/SQL
Microsoft T-SQL
Sybase T-SQL
Technical Criterion
Efficiency - SQL and Data Handling Performance
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.