PGSQL: Which is faster, many constraints or a single trigger? I have a table that currently has 12 check constraints. I'm making some updates and I'm wondering if this is the best approach. I see three options:


Keep using the 12 constraints. They're a bit difficult to understand, but definitely possible.
Craft one massive constraint that no feeble human mind could ever understand or maintain.
Use an insert or update trigger to validate contents. This is a dream to implement and maintain.


I'm aware that a trigger will not validate existing rows. For this use case, that is acceptable.

Obviously, I like #3, but I'd some like input regarding performance of inserts and updates before actually implementing anything.
A short answer would be: generally check constraints are faster than triggers.

However, if you think a trigger will be easier to maintain than multiple check constraints, do not hesitate and try this solution. Performance deterioration will not be high. I used this solution a few times, in all cases the triggers were up to 10-15% slower than check constraints. In my opinion this is not an exorbitant price for the extra capabilities and flexibility that triggers give. 

An additional important advantage of triggers is that you may reject incorrect rows instead of raising an exception, which can be particularly comfortable in bulk inserts or updates. Information on rejected rows should be stored in some way, e.g. in a form of a log, in an auxiliary (temporary) table or using notifies.