1. Home >
  2. Apps >
  3. Groups >

MySQL: Does foreign key reference/constraint speed up the query?

Question asked by Kaustubh Katdare in #Coffee Room on Sep 30, 2018
Kaustubh Katdare
Kaustubh Katdare · Sep 30, 2018
Rank A1 - PRO

I'm wondering if adding foreign key constraints and references has any performance improvements in MySQL queries. 

For example, let's say I've a posts table -

post_id | user_id | title | ....

and a users table 

id | username | password | ....

and on this table, I define 

foreign_key (user_id) references -> 'id' on users

Will this have any performance improvements over NOT adding the foreign key reference? 

I researched this a bit on the Internet and found out that some of the articles claim that it does improve the performance; but don't mention why, and how. Would really appreciate if someone could explain this. 

PS: The tables I'm talking about are all InnoDB. 

Posted in: #Coffee Room

You must log-in or sign-up to reply to this post.

Click to Log-In or Sign-Up