Medlemsträff i Stockholm 2011-01-24
Agenda 12.30 – 13.30 Lunch and social gathering 13.30 – 13.45 Introduction 13.45 – 14.45 Raoul Illyés: Stop guessing! 14.45 – 15.00 Break 15.00 – 16.30 Joe Chang: The SQL Server Query Optimizer Cost Formulas 16.30 – 17.00 Q&A with Joe and Raoul
Sponsorer
SQLug.se Information PASS Chapter Ideell förening registrerad Årets aktiviteter 5 träffar i Sthlm 2011 Talare sökes! PASS konf i November SQLUG lag till Triathlon SQLUG Challenge
Xevent by Raoul Illyés rai@guide-line.com rai@guide-line.com
Who am i? 17 years of IT Experiance SQL MVP since October 2010 Owner of Guide-line since 2010 rai@guide-line.com rai@guide-line.com
History In 2007 was invited to Redmond to demonstrate the Oracles way of instrumentation. They showed me an alpha version of Extended events. rai@guide-line.com
History A 1000 mails later back and forth i was in 2008 invited back to Redmond to work with Xevent for 2 hole weeks. The aim was to create some form of tool to demonstrate Its powers, the result was.. rai@guide-line.com
Response Time Analysis using Extended Events http://sqlcat.codeplex.com/wikipage?title=ExtendedEventsWaitstats&referringTitle=Home rai@guide-line.com
Then many, many presentations later nothing has really happened rai@guide-line.com
The main reason for this is: Complexity! (NO UI) CREATE EVENT SESSION event_session_name ON SERVER { <event_definition> [ ,...n] [ <event_target_definition> [ ,...n] ] [ WITH ( <event_session_options> [ ,...n] ) ] } ; <event_definition>::= { ADD EVENT [event_module_guid].event_package_name.event_name [ ( { [ SET { event_customizable_attribute = <value> [ ,...n] } ] [ ACTION ( { [event_module_guid].event_package_name.action_name [ ,...n] } ) ] [ WHERE <predicate_expression> ] } ) ] } <predicate_expression> ::= { [ NOT ] <predicate_factor> | {( <predicate_expression> ) } [ { AND | OR } [ NOT ] { <predicate_factor> | ( <predicate_expression> ) } ] [ ,...n ] } <predicate_factor>::= { <predicate_leaf> | ( <predicate_expression> ) } <predicate_leaf>::= { <predicate_source_declaration> { = | < > | ! = | > | > = | < | < = } <value> | [event_module_guid].event_package_name.predicate_compare_name ( <predicate_source_declaration>, <value> ) } <predicate_source_declaration>::= { event_field_name | ( [event_module_guid].event_package_name.predicate_source_name ) } <value>::= { number | 'string' } <event_target_definition>::= { ADD TARGET [event_module_guid].event_package_name.target_name [ ( SET { target_parameter_name = <value> [ ,...n] } ) ] } <event_session_options>::= { [ MAX_MEMORY = size [ KB | MB ] ] [ [,] EVENT_RETENTION_MODE = { ALLOW_SINGLE_EVENT_LOSS | ALLOW_MULTIPLE_EVENT_LOSS | NO_EVENT_LOSS } ] [ [,] MAX_DISPATCH_LATENCY = { seconds SECONDS | INFINITE } ] [ [,] MAX_EVENT_SIZE = size [ KB | MB ] ] [ [,] MEMORY_PARTITION_MODE = { NONE | PER_NODE | PER_CPU } ] [ [,] TRACK_CAUSALITY = { ON | OFF } ] [ [,] STARTUP_STATE = { ON | OFF } ] } rai@guide-line.com
2. Non friendly providers for the DBA. rai@guide-line.com
(SQL Server 2008 Extended Events SSMS Addin) So what have changed? Jonathan gave us a UI to use to interact with Extended events (SQL Server 2008 Extended Events SSMS Addin) http://extendedeventmanager.codeplex.com/ 2. Microsoft will bring their own in SQL11 rai@guide-line.com
What is Xevent? The new low level, high performance eventing system in SQL Server. Used correctly Xevent will make you stop guessing! rai@guide-line.com
Xevent is implemented through a couple of packages Just like “Profiler” is. Packages Currently there are 4 packages available: Package0 (default, meta objects) Sqlos (OS Related) Sqlserver (Profiler counter part) SecAudit (is private and used only for the built-in SQL Server auditing) select * from sys.dm_xe_packages Module (sqlserver.exe) Packages rai@guide-line.com
And inside the Xevent packages we have the objects Packages are containers Each package must have a GUID and a name Can contain any or all of: Event Target Action Predicate Type Map Module (sqlserver.exe) Packages Events Targets Actions Types Predicates Maps rai@guide-line.com
Xevent building blocks Events Events are points in code that we can trace and currently there are about 254 events defined in SQL Server 2008, 259 2008 R2: SELECT * FROM sys.dm_xe_objects WHERE object_type = 'event' ORDER BY name DEMO 1 rai@guide-line.com
Life of an event rai@guide-line.com
Xevent building blocks Targets Targets are the consumers of the events, there are currently 6 targets available in SQL Server 2008: Event bucketing Event pairing ETW target Event file Synchronous event counter Ring buffer SELECT * FROM sys.dm_xe_objects WHERE object_type = 'target' ORDER BY name rai@guide-line.com rai@guide-line.com
Xevent building blocks And a lot more that we don't have the time to dwell upon.… Predicates Actions Sessions Types and Maps rai@guide-line.com
History lane, different tools for different things. Perfmon ETW Sysinternals Windows Server “Huston we have a problem, but where To begin?” SQL Server Tools: Profiler Server trace System tables DMV & DMF´s rai@guide-line.com
The Profiler aggregation problem. rai@guide-line.com
The [sys].[dm_os_wait_stats] scope problem. rai@guide-line.com
The [sys].[dm_exec_requests] sampling problem. rai@guide-line.com
The Xevent Way! DEMO 2 DBCC DROPCLEANBUFFERS; GO USE AdventureWorks SELECT p.Name AS ProductName, NonDiscountSales = (OrderQty * UnitPrice), Discounts = ((OrderQty * UnitPrice) * UnitPriceDiscount) FROM Production.Product AS p INNER JOIN Sales.SalesOrderDetail AS sod ON p.ProductID = sod.ProductID ORDER BY ProductName DESC; --SELECT TOP 1000 [wait_type] -- ,[waiting_tasks_count] -- ,[wait_time_ms] -- ,[max_wait_time_ms] -- ,[signal_wait_time_ms] -- FROM [AdventureWorks].[sys].[dm_os_wait_stat DEMO 2 rai@guide-line.com rai@guide-line.com
System_health What is that? Created by the Product Support team (PSS) keeps track of information commonly use to debug customer systems, such as: when a deadlock or a high-severity error occurs. The session is created and started as part of the install process for a SQL Server >= 2008 instance using the ring buffer target. DEMO 3 rai@guide-line.com rai@guide-line.com
(To come to a class near you!) What about end-to-end trace? From IIS to SQL Server, SQL Server to SAN and then back again we use the ETW target. (To come to a class near you!) rai@guide-line.com rai@guide-line.com
Almost no cost in running a Xevent trace. A round-up. Almost no cost in running a Xevent trace. Test by Microsoft revels that 20,000 events/sec trace on a 2 GHZ Pentium with 1 GB RAM takes less than 2% of the CPU, Wow! Xevent data is not stored as XML, but the providers made available to interpret the data dose (Except ETW.) Server 1 Server 2 Server 3 rai@guide-line.com rai@guide-line.com