Quantcast
Viewing all articles
Browse latest Browse all 35

Efficiency of foreign keys

If I have a table A which has a composite (two column) foreign key on another table B, should I:

  • a) create a two-column key in B to match the foreign key in A?
  • b) or, MySQL automatically creates the 'missing key' in B to match A's foreign key?
  • c) or, if neither a) nor b) should I assume MySQL might do a table scan on inserting into A?

I'm trying to avoid dubious keys in B as my index already grows at an alarming rate. However, I do not want to penalize insertion/updates into A and would rather take the index growth hit.

Please advise.


Viewing all articles
Browse latest Browse all 35

Trending Articles