问题
What does this mean and how can I fix it?
回答1:
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.
回答2:
It looks to me that it's saying both of these indices have the exact same properties and just have different Keynames, having two indices will create extra storage space as well as run-time to inserts (there is no reason to do this that I can think of) more detail on the topic can be found here:
http://dev.mysql.com/doc/refman/5.0/en/mysql-indexes.html
http://dev.mysql.com/doc/refman/5.0/en/create-index.html
the PRIMARY one is created by phpMyAdmin I believe and it appears the index one was created manually, but is a duplication of work.
来源:https://stackoverflow.com/questions/5506417/what-does-the-indexes-primary-and-id-seem-to-be-equal-and-one-of-them-could-pos