Extended EventsNot so tricky as you might thinkJonathan Allen@fatherjacksqlsouthwest.co.uk
Who on Earth is Jonathan Allen?   Local Government 13 years – accountancy / tax collection.   Systems engineer and DBA s...
Whats coming up• XE - architecture and components.• What can Extended Events show us?• Getting started.• System Health Ext...
Extended Events don’t bite
(Image recreated by Jonathan Allen from MSDN/Books online)
(Image recreated by Jonathan Allen from MSDN/Books online)
(Image recreated by Jonathan Allen from MSDN/Books online)
(Image recreated by Jonathan Allen from MSDN/Books online)
(Image recreated by Jonathan Allen from MSDN/Books online)
(Image recreated by Jonathan Allen from MSDN/Books online)
(Image recreated by Jonathan Allen from MSDN/Books online)
(Image recreated by Jonathan Allen from MSDN/Books online)
(Image recreated by Jonathan Allen from MSDN/Books online)
What can Extended Events show us?From BOL: Troubleshooting excessive CPU usage You are investigating excessive CPU usage o...
Working with Extended EventsOptions• SQL 2008, 2008 R2  – TSQL  – Extended Events Session Explorer• SQL 2012  – TSQL  – SS...
Demos• SSMS 2005/8/R2  – Catching errors  – Identifying slow queries• 2012  – Spotting deprecation issues  – System health...
Demo
XE Best Practice / RecommendationsConsider• Target – Sync or Async• Storage – type, size• Retention – No_Event_Loss or  Al...
Reference• Jonathan Kehayias   –   http://twitter.com/#!/sqlpoolboy / http://www.sqlskills.com   –   http://extendedeventm...
Reference• SQL 2012 SSRS performance reports   –   http://www.microsoft.com/download/en/details.aspx?id=29063• Books Onlin...
Contact me•   Blog – http://www.simple-talk.com/community/blogs/jonathanallen•   SQL forum moderator – http://ask.sqlserve...
Extended events
Upcoming SlideShare
Loading in …5
×

Extended events

1,367 views
1,318 views

Published on

My "Extended Events - Not so tricky as you might think" slide deck from SQL Bits X

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
1,367
On SlideShare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
23
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide
  • Career historySQL historyCommunity content
  • How many people are moving to SQL 2012 right away?Count using versions – 2000 ?!, 2005, 2008+R2Does any have experience of writing code – C, VB, etc ?Taking you from what Extended Events are and how they fit in with SQL Server, through using the default session to keep an eye on your servers to creating your own Event Sessions to check for important events and potential problems.
  • How many people are moving to SQL 2012 right away?Count using versions – 2000 ?!, 2005, 2008+R2Does any have experience of writing code – C, VB, etc ?Taking you from what Extended Events are and how they fit in with SQL Server, through using the default session to keep an eye on your servers to creating your own Event Sessions to check for important events and potential problems.
  • Lightweight event handling platform, specifically designed to be used to trouble shoot performance issue and monitoring system performancePreviously to SQL 2005 SQL Trace has been used but always had the overhead, or at least the concern of it, and the risk of masking the issue or making it worse. You could use “server side traces” rather than the SQL Profiler tool but it was still a measurable drag on the system it was monitoring.
  • Packages are the containers, or groups, for events. There are four packages registered to the Extended Events engine, although one of those is essentially inaccessible to the DBA, and they contain between them all Extended Events objects.
  • Events – these are known points in code that are of interest. They are categorised in such a way as to align with ETW categories. Channels (interested party – Admin, analytic, Debug + Operational) and keywordsActions – these extend the event in various ways, collecting extra data, aggregating data, getting a stack dump storing state information and even adding a debug breakpoint. Be careful using that one. SQL Server stops!Types –The type is the format of the event data, int32, unicode_stringetcMaps – the way to decode the internal values to an english descriptionTargets – where the collected information is sent. Some targets are only usable with sync or async collection, some can work with both.Predicates – effectively the where clause of the event data collection. Supporting short circuiting so as to allow for max efficiency in what data is collected. Evaluated to a boolean true/false
  • A session is a collection of events (including the specified actions and predicates), the targets that have been configured and the details of the buffers where the collected data will be sent/stored
  • Some buffers EG a Deadlock session may have the [sqlserver].[xml_deadlock_reported] event with the [Package0].[ring_buffer] set to a 2MB memory limitA StmtCompleted session might catch the [sqlserver].[sql_statement_completed] event and use the [Package0].[ring_buffer] with a Max_memory setting of 8MB
  • The pool of threads which make up the mechanism throughwhich the session output it gathered and passed into the chosen targets.Details from sys.dm_os_dispatcher_pools
  • The individual thread.
  • Several common examples in Books Online but XE can do so much more.Detecting excessive CPU, Deadlocks, Page Splits, Plan Cache use / non-use the list goes on.
  • Introduced in 2005 so if you manage 2000 then you still need to use Profiler/TraceNo GUI until Jonathan Kehayias created the XE Session Explorer SSMS addin – available via codeplex
  • Extended events

    1. 1. Extended EventsNot so tricky as you might thinkJonathan Allen@fatherjacksqlsouthwest.co.uk
    2. 2. Who on Earth is Jonathan Allen? Local Government 13 years – accountancy / tax collection. Systems engineer and DBA since 1999 SQL Server 6.5, 7, 2000, 2005 and 2008+R2, 2012 Blog, Twitter, SQL South West user group
    3. 3. Whats coming up• XE - architecture and components.• What can Extended Events show us?• Getting started.• System Health Extended Events session.• Working with XE. – T-SQL. – Extended Events manager SSMS Add-in. – SQL Server 2012 interface.
    4. 4. Extended Events don’t bite
    5. 5. (Image recreated by Jonathan Allen from MSDN/Books online)
    6. 6. (Image recreated by Jonathan Allen from MSDN/Books online)
    7. 7. (Image recreated by Jonathan Allen from MSDN/Books online)
    8. 8. (Image recreated by Jonathan Allen from MSDN/Books online)
    9. 9. (Image recreated by Jonathan Allen from MSDN/Books online)
    10. 10. (Image recreated by Jonathan Allen from MSDN/Books online)
    11. 11. (Image recreated by Jonathan Allen from MSDN/Books online)
    12. 12. (Image recreated by Jonathan Allen from MSDN/Books online)
    13. 13. (Image recreated by Jonathan Allen from MSDN/Books online)
    14. 14. What can Extended Events show us?From BOL: Troubleshooting excessive CPU usage You are investigating excessive CPU usage on your production system. You use various Dynamic Management Views (DMVs) to determine if the CPU usage can be attributed to queries that were run on the system. This examination indicates that most of the queries are ad-hoc user queries. The information obtained from the DMVs is not enough to diagnose the problem. You create an Extended Events session that: • Enables events for statement completion with predicates that specify CPU threshold. • Has an action to only collect the query plan when the event fires. • Writes any data that is collected to a file. This file is on a drive that does not contain any log or database files. After starting the Extended Events session you examine the output and are able to determine that the cause of the CPU problem is a data type conversion between two commonly joined tables.(http://msdn.microsoft.com/en-us/library/bb630354(SQL.100).aspx)
    15. 15. Working with Extended EventsOptions• SQL 2008, 2008 R2 – TSQL – Extended Events Session Explorer• SQL 2012 – TSQL – SSMS (not effective on prev. versions)
    16. 16. Demos• SSMS 2005/8/R2 – Catching errors – Identifying slow queries• 2012 – Spotting deprecation issues – System health session
    17. 17. Demo
    18. 18. XE Best Practice / RecommendationsConsider• Target – Sync or Async• Storage – type, size• Retention – No_Event_Loss or Allow_Single_Event_Loss/Allow_multiple_Event_Loss• Use SSMS 2012 to build session, script it, apply to 2008
    19. 19. Reference• Jonathan Kehayias – http://twitter.com/#!/sqlpoolboy / http://www.sqlskills.com – http://extendedeventmanager.codeplex.com/ – http://sqlblog.com/blogs/jonathan_kehayias/archive/2010/12.aspx• MVP Deep Dives 1 – Chapter 49 by Christian Lefter – via Amazon among other book sellers• SQL Server 2008 Internals and Troubleshooting – (Bolton, Langford, Ozar, Rowland-jones, Wort) via Amazon among other book sellers• Adam Machanic – blog (code generator/tips+advice) – http://sqlblog.com/blogs/adam_machanic/archive/tags/extended+events/default.aspx
    20. 20. Reference• SQL 2012 SSRS performance reports – http://www.microsoft.com/download/en/details.aspx?id=29063• Books Online – 2008 - http://msdn.microsoft.com/en-us/library/bb677357(v=SQL.100).aspx – 2012 - http://msdn.microsoft.com/en-us/library/ms130214(v=sql.110).aspx• MSDN Convert Trace to XE article – http://msdn.microsoft.com/en-us/library/ff878114(v=sql.110).aspx• MSDN Blog – Grant Fritchey – http://blogs.msdn.com/b/microsoft_press/archive/2012/03/21/from-the-mvps-a-gui-for-extended- events-in-sql-server-2012.aspx
    21. 21. Contact me• Blog – http://www.simple-talk.com/community/blogs/jonathanallen• SQL forum moderator – http://ask.sqlservercentral.com• Twitter - @Fatherjack• SQLSouthWest User Group leader – jonathan@sqlsouthwest.co.uk• PASS UK Regional Mentor – http://sqlpass.org / ukrm@sqlpass.org• Friend of Red Gate - http://www.red-gate.com Jonathan Allen © - May 2011

    ×