Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Same index name for two tables

Tags:

mysql

I am working on building a small Mysql database for our team. For two tables in my db, I used the same index name.

Would there be any performance hit?

I did a few tests queries (800,000+ rows) and so far, so good.

like image 447
Chris Avatar asked Sep 08 '11 17:09

Chris


People also ask

Can an index be associated with multiple tables?

Yep, indexed views are the answer. You can join the two tables in a view and create a unique clustered index on the view for the required columns.

Can we create two tables with same name?

You can have tables of the same name only if they are in separate databases, and you use the database name as a qualifier.

Can we create multiple index on same column mysql?

Yes, it can have an effect. Of course the two indexes take extra space on disk and also in memory if they are used.


3 Answers

Index names are specific to each table. You cannot have two indexes of the same name in one table, but you can have many indexes of the same name, one for every table. Index names are irrelevant for day-to-day performance. They're simply there to provide a nice user-friendly way to refer to the index without having to list all the fields in the index. e.g. it's easier to say alter table XXX drop key friendlyname than alter table XXX drop key (field1, field2, field3, field4, field5, etc...)

like image 200
Marc B Avatar answered Nov 12 '22 16:11

Marc B


Index names are per table, there shouldn't be any concern.

like image 41
nobody Avatar answered Nov 12 '22 16:11

nobody


No. The index name is completely inconsequential to performance.

like image 41
Lightness Races in Orbit Avatar answered Nov 12 '22 16:11

Lightness Races in Orbit