This is a discussion on Primary, index, unique.... within the MySQL Database forums, part of the Database Forums category; Hi, I'm getting improvement messages from PhpMyAdmin pages and would like to ask about something. On many tables I'...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
Hi, I'm getting improvement messages from PhpMyAdmin pages and would like to
ask about something. On many tables I've a primary key and also indexes on the same field, to improve search performances. On PhpMyAdmin there is a message telling I should remove the index. Does the primary key automatically create an index so no need to a second one on the same field ? Here is my "worse" table index description, with 2 errors: The message say to delete the unique and index as there is already a primary key. Nom de l'index Type Cardinalité Champ PRIMARY PRIMARY 2326 IDAnnounce IDannounce UNIQUE 2326 IDAnnounce AI_IDannounce INDEX 2326 IDAnnounce May I simply delete Unique key (IDAnnounce) and unique index (AI_IDannounce) without affecting table performances ? Thanks for helping, as I've many tables with quite the same problem (primary and unique on the same field) and inserting or deleting performance are somewhat affected by such indexes. If I don't need those index as primary already I will delete them. Thanks for helping. |
|
|||
|
On 19 May, 07:43, "Bob Bedford" <b...@bedford.com> wrote:
> Hi, I'm getting improvement messages from PhpMyAdmin pages and would like to > ask about something. > > On many tables I've a primary key and also indexes on the same field, to > improve search performances. On PhpMyAdmin there is a message telling I > should remove the index. Does the primary key automatically create an index > so no need to a second one on the same field ? > > Here is my "worse" table index description, with 2 errors: > The message say to delete the unique and index as there is already a primary > key. > > Nom de l'index Type Cardinalité Champ > PRIMARY PRIMARY 2326 IDAnnounce > IDannounce UNIQUE 2326 IDAnnounce > AI_IDannounce INDEX 2326 IDAnnounce > > May I simply delete Unique key (IDAnnounce) and unique index (AI_IDannounce) > without affecting table performances ? > > Thanks for helping, as I've many tables with quite the same problem (primary > and unique on the same field) and inserting or deleting performance are > somewhat affected by such indexes. If I don't need those index as primary > already I will delete them. > > Thanks for helping. In future you might try finding the answer yourself using Google. I searched on: primary key index The "I'm feeling lucky" hit was to a page in the manual where it said: A PRIMARY KEY is a unique index where all key columns must be defined as NOT NULL. If they are not explicitly declared as NOT NULL, MySQL declares them so implicitly (and silently). A table can have only one PRIMARY KEY. If you do not have a PRIMARY KEY and an application asks for the PRIMARY KEY in your tables, MySQL returns the first UNIQUE index that has no NULL columns as the PRIMARY KEY. If instead of hitting "I'm Feeling Lucky", you looked at the search results list you would see: "MySQL has three types of indexes: INDEX, UNIQUE (which requires each row to have a unique value), and PRIMARY KEY (which is just a particular UNIQUE index). ..." You learn a lot more by doing it yourself, rather than asking others to look these things up for you. |