Rule Definition
Every index increases the time it takes to perform INSERTS, UPDATES and DELETES, so the number of indexes should not be too high. Try to not use more than a maximum of 4-5 indexes for one table. If you have a read-only table, then the number of indexes is not as important and thus may be larger.
Remediation
Drop unecessary indexes.
Violation Code Sample
-- SQL Server Sample
create table MyManyIndexTable( C1 int, C2 int, C3 int, C4 int, C5 int)
create index MyManyIndexTable_I1 on MyManyIndexTable( C1)
create index MyManyIndexTable_I2 on MyManyIndexTable( C2)
create index MyManyIndexTable_I3 on MyManyIndexTable( C3)
create index MyManyIndexTable_I4 on MyManyIndexTable( C4)
create index MyManyIndexTable_I5 on MyManyIndexTable( C5)
declare @t datetime
declare @i int
Set @i = 1
set @t = getdate()
while (@i < 5000)
begin
insert MyManyIndexTable select @i,@i,@i,@i,@i
set @i = @i+1
end
SELECT DATEDIFF(ms, @t, getdate()) as 'Elapsed Time'
=> 3806 ms
Fixed Code Sample
Drop the index & empty the table
=> 2563 ms
Related Technologies
DB2 Server
Forms
PL/SQL
Microsoft T-SQL
Sybase T-SQL
DB2 z/OS
SQLScript
Technical Criterion
CWE-1089 - Large Data Table with Excessive Number of Indices
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.