February 24, 2018 at 12:03 am
Hi Team,
I have created one single trigger to capture information modified by the insert/update/delete commands.
is there any performance difference if we create 3 separate triggers(like after insert ,after update ,after delete) ?
Thanks in Advance.
Dastagiri D
February 24, 2018 at 7:01 am
dastagiri16 - Saturday, February 24, 2018 12:03 AMHi Team,
I have created one single trigger to capture information modified by the insert/update/delete commands.is there any performance difference if we create 3 separate triggers(like after insert ,after update ,after delete) ?
Thanks in Advance.
Dastagiri D
Maybe... "It Depends" on how you write them. I've not done such a study but SQL Server is pretty fast about deciding what the triggering event was and, since any given event can only be one of the three (Insert, Update, or Delete), it may cost you more to write code in a single trigger to make a decision as to which event occurred than if you had three different dedicated triggers.
The real key is to ask what the/these triggers will be used for. For example, if you're using triggers to populate audit tables, then it's a serious mistake to use the "INSERTED" logical table of any trigger and you certainly should not have a separate "INSERT" trigger because auditing inserts instantly doubles your storage requirements for what will likely become the biggest table in your entire database.
With that in mind, what are you using this/these triggers for?
--Jeff Moden
Change is inevitable... Change for the better is not.
February 26, 2018 at 5:03 pm
No. In fact, generally they are a bit faster since you don't have to decide within the trigger which action -- DELETE / INSERT / UPDATE -- has occurred.
SQL DBA,SQL Server MVP(07, 08, 09) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply