MySQL Forums
Forum List  »  Performance

Re: Pre-DML trigger vs Foreign keys
Posted by: Rick James
Date: June 23, 2012 01:56PM

What do you want the trigger/FK to do?

Why do you want to do it with a trigger/FK instead of being in direct control in your app?

If you are doing fewer than 100 queries/sec, performance is a non-issue.

Back to your question... Here are some principles to use to figure out the answer:
* A FK will reach into the 'other' table to check for the existence/absence of the corresponding row. This takes some effort. If the dataset is big enough, this is likely to be a disk hit.
* A TRIGGER must interpretively perform the instructions indicate. If these are hitting some other table, then the cost of that must be considered.

It sounds like you are suggesting simulating a FK using a Trigger. As a general principle, a simulation is going to be slower than the 'real thing'.

Options: ReplyQuote


Subject
Views
Written By
Posted
Re: Pre-DML trigger vs Foreign keys
1047
June 23, 2012 01:56PM
1115
June 23, 2012 05:18PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.