I have a single SQL Server table with 10 different triggers that fire on the same INSERT and UPDATE.
Is there any performance advantage to consolidating the SQL inside the 10 triggers into a single trigger?
The single consolidated trigger would do the same thing as the 10 different triggers, but only one trigger would get fired instead of 10.
Thanks!
Update: Thanks for the great feedback. I updated my question to indicate that I am wondering about performance advantages. I didn’t think of the “absolute control over order” advantage. I am aware that these various triggers should be refactored at some point, but am wondering more about performance of one versus many triggers.
Consolidating triggers can make a huge performance boost. For example consider the following table, two triggers, and an update:
This update uses 1671 ms CPU and 4M reads. Let’s consolidate two triggers and rerun the update:
The same update runs twice us fast. Big surprise. 😉