Subject | Check constraints vs. user defined triggers |
---|---|
Author | Aldo Caruso |
Post date | 2014-12-30T02:56:09Z |
Hi,
I have a table with four check constraints, which basically check
logical conditions between its fields.
In order to enforce those constraints, Firebird creates behind the
scenes two triggers for each one of them (I suppose one for update and
the other for insert operation). So in this case it ends up with eight
system created triggers.
I suppose this degradates performance of massive insert or updates, as
four triggers have to be launched for each insert or update operation.
Does it have sense in order to enhace performance not to use check
contraints but instead check those constraints globally using only two
user defined triggers (before insert and before update), raising
exceptions when logical conditions aren't met ?
Is it worthwhile ? Which are the pros and cons of this approach ?
Thanks for your opinion.
Aldo
I have a table with four check constraints, which basically check
logical conditions between its fields.
In order to enforce those constraints, Firebird creates behind the
scenes two triggers for each one of them (I suppose one for update and
the other for insert operation). So in this case it ends up with eight
system created triggers.
I suppose this degradates performance of massive insert or updates, as
four triggers have to be launched for each insert or update operation.
Does it have sense in order to enhace performance not to use check
contraints but instead check those constraints globally using only two
user defined triggers (before insert and before update), raising
exceptions when logical conditions aren't met ?
Is it worthwhile ? Which are the pros and cons of this approach ?
Thanks for your opinion.
Aldo