mysql - Why InnoDB adds index for foreign key column -


mysql auto adding index when adding foreign key column in mysql innodb engine. primary key enough search rows, how affect performance adding index foreign key column.

thanks in advance.

mysql docs state reasoning behind here

mysql requires indexes on foreign keys , referenced keys foreign key checks can fast , not require table scan. in referencing table, there must index foreign key columns listed first columns in same order. such index created on referencing table automatically if not exist.

there many queries typically joins require rows match on basis of foreign keys , database has find rows. index typically helps faster.


Comments

Popular posts from this blog

javascript - Chart.js (Radar Chart) different scaleLineColor for each scaleLine -

apache - Error with PHP mail(): Multiple or malformed newlines found in additional_header -

java - Android – MapFragment overlay button shadow, just like MyLocation button -