Triggers == Bad Performance?
I was reading the new MSDN Magazine and came upon an article on SQL Triggers written by John Papa. He does a good job of explaining what they are and how they work. I would like to bring attention to the second to last paragraph called Performance.
I've “heard” and “been told” that triggers are bad for performance. John does a good job of spelling out when they are “the right tool for the job”. Following are a few good tips he gave:
- Triggers are not slow, the logic inside is what causes the perf hit. (e.g. cursors, multi-table traversal, ..)
- Try to just work with the dynamic inserted and deleted tables
- Triggers are compiled
- Do not return resultsets
- Keep it simple
Sounds good to me. As long as I don't put too much weight on the backs of the triggers, and try and avoid confusion by having them talk to each other in complex loops; I think I can now use them with a clear conscience and I won't worry about causing my SQL server to die.