I’ve been asked questions about these two features a number of times in the last year where the specific concepts for them have been severely confused. Since I have used the same information each time I’ve answered these questions I figured it would be worth blogging about here as a reference as well.
Event Notifications were introduced in SQL Server 2005 and offer the ability to collect a very specific subset of SQL Trace (http://msdn.microsoft.com/en-us/library/ms190655.aspx) and DDL Events (http://msdn.microsoft.com/en-us/library/bb522542.aspx) through a Service Broker service and queue. The use of Service Broker allows you to write stored procedures that can process the events asynchronously when they are placed on the queue through a functionality of Service Broker known as queue activation. You can also make use of remote servicing that allows the event data to be sent from one SQL Server to another for processing which is very useful in larger environments where you want to centralize all of the events for reporting.
Extended Events were introduced in SQL Server 2008 and use entirely different architecture inside of the database engine for providing events. Extended Events contain a number of events that are not available by any other means in SQL Server, but there are a number of events in SQL Trace that are not available in Extended Events in SQL Server 2008; for example the blocked process report is not available by Extended Events. In SQL Server 2012 RTM, all of the events from SQL Trace have been implemented in Extended Events, and Extended Events will replace SQL Trace entirely in a future release of SQL Server since SQL Trace is a newly deprecated feature in 2012 (deprecated = slated for removal in 2-3 product life cycles, it does not mean removed entirely).
The key difference between the two features is that Event Notifications allow automated processing of the events asynchronously through Service Broker. There is no similar mechanism for Extended Events currently; even in SQL Server 2012 where Event Notifications still piggy back SQL Trace for event generation. If you are interested in building an alerting infrastructure I would still use Event Notifications depending on the information that you are interested in gathering. To build an alerting solution on top of Extended Events would require consistently polling the event session targets and tracking which events have already been seen by the solution in SQL Server 2008, and in SQL Server 2012 it would require the same kind of polling solution unless you wrote a .NET application to leverage the streaming API for Extended Events to harvest the events in real time. Depending on the event frequency and target being used either of these solutions could lead to missed alerts or an expensive polling operation that reads the same information repeatedly.
Either feature can safely be used in a highly transactional system if the appropriate considerations are made in the implementation, and either feature can lead to performance impacts as well. It all depends on the events being collected and how frequently they get fired. The events that are available in Event Notifications are a generally safe subset of the events from SQL Trace and generally won’t cause performance problems, but your mileage may very based on the frequency of the events firing. As always you should test the event selection and monitor for impact after implementing a change to the system.
I hope this helps anyone interested in these two features.
4 thoughts on “Event Notifications vs Extended Events”
For mornitoring and alerting purpose, Event Notification is more suitable which is what I am doing in our environment. For example, monitor file autogrowth event (thanks for your article on this topic). It’s very useful. One day some our network guy added a lot devices into their network monitoring system which generated huge amount of log entries in some log tables and the purging job also had to delete lots of records and index maintenance task had to rebuild the indexes. Well, non-surprisingly, sql log file had to expand time and time again. With the alerting, we knew what happened which led us to discussing how they can reduce logging in the system, how many devices they are looking to add so we can prepare the size of log file and change the log backup frequency.
I was actully investigating to see if we can use extended events for alerting. Then I found I can’t (at least not as easy as Event Notification). So it’s very nice to see you have this expained in this post. Thanks Jonathan.
Read Martin Catherall’s post today and knew there is a Connect and I voted.
https://connect.microsoft.com/SQLServer/feedback/details/782941/support-sql-broker-service-to-be-a-target-of-extended-events