What does this mean and how can I fix it?
You have two separate indexes on the same field of your table (id
). One of them is implied by having set id
as a PRIMARY KEY
, the other you probably created explicitly. Only one of them is needed - having both of them may result in performance drop due to the additional index updates.
Just drop one of them to resolve this issue.
Having a PRIMARY KEY
or UNIQUE
constraint on a column (or field, if you wish) of a table essentially means that for each row inserted, the value of that column should be unique and therefore it should not already exist in the table. The naive approach would be to read all existing rows before inserting, but that would make the DB very slow once a number of rows has been inserted.
In order to deal with this, most (all?) decent database engines will implicitly create indexes for such fields, so that they can quickly detect if a value already exists in the table, without having to scan all its rows.
As a result, manually creating indexes on fields declared PRIMARY KEY
or UNIQUE
not only is redudant, but it may also cause performance loss due to the duplication of the work needed to maintain the indexes.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With