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

    Kaustubh Katdare

    Kaustubh Katdare

    @thebigk
    Updated: Sep 30, 2018
    Views: 1.4K

    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. 

    0
    Replies
Howdy guest!
Dear guest, you must be logged-in to participate on CrazyEngineers. We would love to have you as a member of our community. Consider creating an account or login.
Home Channels Search Login Register