February 28, 2011 at 5:12 am
Hi,
I would like to know the difference between disabling and dropping a trigger. To me, Trigger is basically coupled with transaction hence write/reads entry from the log for the action. If that is the case, disabling a trigger would only stop the read operation however the write happens to the transaction log. For a big table with more transactions(updates/delete/insert), it would be great if we can drop the trigger instead of disabling so I can save the log file growth. So dropping a trigger would be the best one rather than disabling if it is not going to use in future.
Please correct me perhaps I am wrong on anything.
February 28, 2011 at 5:47 am
If you aren't going to use the trigger anymore, drop it. If you do plan on using it in the future, I would disable it. Another alternative is to script the trigger out and recreate it/drop it with a script or job.
February 28, 2011 at 5:59 am
Whether you have triggers on a table or not has no bearing on whether transactions are written to the transaction log. All transactional operations are logged (in all recovery models) so you will not gain anything tangible by dropping vs disabling a trigger.
Also, triggers do not operate asyncronously, somehow mining the transaction log. They will be fired for each relevant DML statement as part of the same transaction.
February 28, 2011 at 5:59 am
Thanks for your comment!!!
Am really looking for an answer or confirmation as how the disabling of a trigger is working. As I mentioned, is this the way that it will log an entry in transaction log but it wont read from it or it wont write the entry at all if it is in disabled state?
February 28, 2011 at 6:05 am
sqlchanakya (2/28/2011)
Am really looking for an answer or confirmation as how the disabling of a trigger is working. As I mentioned, is this the way that it will log an entry in transaction log but it wont read from it or it wont write the entry at all if it is in disabled state?
No, triggers have absolutely no effect on whether the original transaction gets logged to the transaction log.
February 28, 2011 at 6:11 am
Could you plese check the below link and correct me where I interpreted wrongly...
http://sqlblogcasts.com/blogs/tonyrogerson/archive/2006/10/27/1248.aspx
February 28, 2011 at 6:26 am
Interesting...
That is written for 2000 (this is the 2008 forum) - what it's saying is that because the inserted and deleted tables need to include all columns, not just the ones affected by the update, some operations may end up with increased logging information.
I've never heard of this before and I can't see any official reference that supports it, but it does make some sense. I suspect that the huge changes between 2000 and 2008 will have changed this one way or another, however I'll see if I can do some digging (if one of the heavy weights hasn't answered it definitively by then)
February 28, 2011 at 6:31 am
Okei, In Paul Randal's blog, he mentioned for SQL 2005 or behind, they changed the way the trigger working. But I could not find how it works.
I would really appreciate if you could help me on the same as you said....I would also definitely look and share the same.
February 28, 2011 at 6:35 am
So, to clarify, which version of SQL Server are you using?
February 28, 2011 at 9:00 am
SQL Server 2008; however 80 compatibility ....
February 28, 2011 at 8:06 pm
HowardW (2/28/2011)
sqlchanakya (2/28/2011)
Am really looking for an answer or confirmation as how the disabling of a trigger is working. As I mentioned, is this the way that it will log an entry in transaction log but it wont read from it or it wont write the entry at all if it is in disabled state?No, triggers have absolutely no effect on whether the original transaction gets logged to the transaction log.
IIRC, they can have an impact on whether minimal logging of bulk loads will take place. I don't believe that's the case here, though.
--Jeff Moden
Change is inevitable... Change for the better is not.
February 28, 2011 at 8:12 pm
I guess my question would be... what does the trigger do?
--Jeff Moden
Change is inevitable... Change for the better is not.
February 28, 2011 at 9:20 pm
Actually, we had a trigger which used to pull data from one db to another db using Service Broker. We changed currently the entire architecture as if we found critical issues in this case. However, we only disabled the triggers. As I read the article mentioned in my previous post, alos the table is undergoing high transactions(insert/update/delete), (replication is also set up on the DB) thought it would be great to stop there by reduce the transaction log size.
From my googling, it was clear that in SQL server 2000, it is very mcuh true the case. Also it is mentioned trigger functionality had a great change in SQL Server 2005. Thought of understanding how it would have done in SQL server 2005 and later there by coming to a conclusion.
Is there any link I can go through about this architectural change in Trigger. I am still googling out, but no clues so far...
February 28, 2011 at 10:46 pm
In SQL 2005 and above, the inserted and deleted tables are materialised from the row version store in TempDB, not the transaction log. Hence they do not cause log reads any longer.
Disabled trigger = metadata retained, trigger not executed at all
Dropped trigger = metadata dropped, trigger completely removed.
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
February 28, 2011 at 11:05 pm
Thank you Gail!!! It is clear now.
However a question behind is the change is applicable for the SQL version or its compatibility. In my case, Compatibility is 80 on SQL server 2008.
Viewing 15 posts - 1 through 15 (of 16 total)
You must be logged in to reply to this topic. Login to reply