SQL Server › Triggers
What are the performance implications of using triggers heavily on a busy, high transaction volume table?
AdvancedAnswer
Triggers execute synchronously as part of the same transaction as the original statement, meaning any additional work performed inside a trigger directly adds to the time that transaction takes to complete and the duration locks are held, so a poorly optimized or overly complex trigger on a very busy table can become a significant performance bottleneck across the entire application.
-- A trigger performing a slow, unindexed lookup
-- will slow down every single insert on this table
CREATE TRIGGER trg_SlowCheck
ON Orders
AFTER INSERT
AS
BEGIN
IF EXISTS (SELECT 1 FROM VeryLargeTable WHERE UnindexedColumn = 'value')
PRINT 'Found';
END;Real-world example A team notices insert performance on their orders table has degraded significantly since adding a trigger, discovering it was performing an unindexed lookup against a large unrelated table, and fixes it by properly indexing that lookup.