Primary, index, unique....

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'...


Go Back   Usenet Forums > Database Forums > MySQL Database

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 05-19-2008
Bob Bedford
 
Posts: n/a
Default Primary, index, unique....

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.


Reply With Quote
  #2 (permalink)  
Old 05-19-2008
Captain Paralytic
 
Posts: n/a
Default Re: Primary, index, unique....

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.
Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 07:01 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0