Presentation is loading. Please wait.

Presentation is loading. Please wait.

SQL Server Baselining, Benchmarking and Workload Analysis

Similar presentations


Presentation on theme: "SQL Server Baselining, Benchmarking and Workload Analysis"— Presentation transcript:

1 SQL Server Baselining, Benchmarking and Workload Analysis
Gianluca Sartori sqlconsulting.it

2 Gianluca Sartori Independent SQL Server consultant
SQL Server MVP, MCTS, MCITP, MCT Works with SQL Server since version 7 Scuderia Ferrari Blog: spaghettidba.com Twitter: @spaghettidba

3 AGENDA Baselining Workload Analysis Benchmarking
What happens in “normal” conditions? Workload Analysis How are applications and databases interacting with each other? Benchmarking What if…?

4 Health Check Why? When? How? Improve performance Improve manageability
Regularly  Assessment Continuously  Monitoring How? A methodology is needed

5 Health Check

6 Baselining Let’s establish what’s normal 9/10/2018 6:34 PM
© 2014 Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

7 What is a baseline? Describes system performance in «normal» conditions Used a comparison basis Monitoring Troubleshooting Trend Analysis and Capacity Planning

8 Creating a baseline What to capture? How to capture? How often?
Where to store the captured data? How long to keep it? How to analyze it?

9 What to capture? General information System SQL Server Version
HW (CPU, RAM, disk…) SQL Server Version and edition Configuration options Database inventory File size and placement

10 What to capture? Performance indicators Wait Stats
Performance Counters Dynamic Management Objects Query Stats

11 Wait Stats DMV  sys.dm_os_wait_stats
Tracks time spent by processes in a wait queue Wait times are cumulative (since last server restart) Great starting point for troubleshooting Allows to identify problems from their symptoms Shows which areas need attention Not all wait classes are meaningful!

12 Wait Stats Common wait classes Resource Class Example Locking LCK_*
LCK_M_S LCK_M_X Latching LATCH_* PAGELATCH_* LATCH_EX PAGELATCH_UP I/O PAGEIOLATCH_* *_COMPLETION WRITELOG PAGEIOLATCH_SH IO_COMPLETION ASYNC_IO_COMPLETION CPU THREADPOOL SOS_SCHEDULER_YIELD Network ASYNC_NETWORK_IO Parallelism CXPACKET

13 Demo WAIT STATS

14 Performance Counters Which counters? CPU Memory Disk SQL – specific …
More than 400 in SQL Server 2016!!!

15 DMO sys.dm_os_ OS information sys.dm_io_ Disk performance
sys.dm_exec_ Sessions, requests, connections sys.dm_db_ Database info sys.dm_tran_ Transactions, locks sys.dm_... Audits, broker, CDC, FileStream, FTS, HADR, Repl, RG, XE… Not all DMOs are performance related

16 Which DMOs? 141 DMOs in SQL Server 2016!!! SELECT name ,type_desc
Periodic Table of SQL Server Dynamic Management Objects 141 DMOs in SQL Server 2016!!! SELECT name ,type_desc FROM sys.all_objects WHERE name LIKE 'dm[_]%' ORDER BY name

17 What to capture? How do you work with 400 performance counters and 141 DMOs? Glenn Berry’s Diagnostic Information Queries Davide Mauri’s SYS2 DMVs Brent Ozar’s sp_Blitz Kendall van Dyke’s SQLPowerDoc

18 Performance Data Collector
Available in all editions (except Express) Contains System Collection Sets Extensible model, custom Collection Sets Extended T-SQL Collector Captures data at regular intervals Data saved in a Management Datawarehouse Multiple instances can share the same MDW May be integrated with Utility Control Point Comes with reports to read and analyze the data Reports can be centralized on Reporting Services:

19 How long to keep the data?
It depends on Available disk space Depth of analysis required Volatility of the environment

20 Which data participate the baseline?
Select a subset of the data captured for monitoring Select baseline regularly “Implicit” selection  previous day/week/month “Explicit” selection  extract a snapshot Only one baseline? Depends on business cycle Depends on applications

21 Business Cycle

22 Monitoring Baseline Compare the instant value of the performance metric with its baseline Baseline must be chosen keeping the business cycle in mind

23 Workload Analysis What drives the load on SQL Server?
9/10/2018 6:34 PM Workload Analysis What drives the load on SQL Server? © 2014 Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

24 Workload Analysis Performance  effect Workload  cause
Workload analysis allows to correlate cause and effect Outcome of analysis is a plan

25 Query Statistics DMV  sys.dm_exec_query_stats
Information on all queries in plan cache Rank queries in terms of: IO Reads Writes CPU Execution count

26 Plan cache analysis Correlate wait stats and query stats
Identify problematic queries Missing indexes Implicit conversions Identify application issues “Plan cache bloat” Since 2012, DTA can use plan cache as a source

27 Query Store New in SQL Server 2016
Data is persisted throughout restarts Allows to find plan regressions Allows “fixing” rogue plans with no effort

28 Demo PLAN CACHE ANALYSIS

29 Trace Often query stats are not enough What to capture with traces?
Volatile Don’t capture queries marked as RECOMPILE What to capture with traces? Events Columns Filters Collection tools Profiler vs. SQLTrace

30 Extended Events Introduced in SQL Server 2008 (eg: Audit)
Expose events deep inside SQLOS Often not available otherwise Lightweight Configurable Replacement for SQL Trace (since 2012) Used to lack some features Analysis tools Replay tools Now 100% covered

31 Workload Analysis What to analyze Analysis tools
Depends on what you captured Correlate with performance counters Analysis tools RML Utilities (ReadTrace) Watch out for trace file version  conversion PSSDIAG SQL Nexus ClearTrace

32 Demo CLEARTRACE

33 Benchmarking Imagine new scenarios… 9/10/2018 6:34 PM
© 2014 Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

34 What is a benchmark? Describes performance in different scenarios
Evaluates whatif scenarios: Hardware/Software Upgrade Virtualization Helps rating tuning efforts Server-wide configuration changes Addition/removal of indexes Code changes

35 Performance benchmarking

36 Workload capture Which tool? Which events should you capture?
SQL Trace vs. Profiler  Prefer SQL Trace Which events should you capture? Which columns should you capture? RML Utilities Trace definition script Backup the database First issue a full backup, then start the trace First run the trace, then issue a full backup Filter the trace

37 Workload replay Prepare the test environment Must be a complete clone
Restore User Databases Keep original database_id! Logins Watch out for orphaned users! Jobs SSIS Packages Database Mail Test environment must be isolated from production!

38 Workload replay Which tool? Profiler RML Utilities - Ostress
Distributed Replay Introduced in SQL Server 2012 Can replay a workload form multiple clients Same query rate of the original trace (synchronization mode)

39 Distributed replay 3 core elements: Administration tool
Distributed Replay Controller Distributed Replay Client

40 Workload replay Which tool?

41 Baseline Capture Reset performance metrics
DBCC SQLPERF("sys.dm_os_wait_stats",CLEAR); DBCC FREEPROCCACHE(); DBCC FREESYSTEMCACHE('ALL'); DBCC DROPCLEANBUFFERS(); Take a snapshot for each database Start collection Performance Monitor Collection Set SQLTrace – RML Template

42 Benchmark Capture Revert to snapshot Apply changes
Start collection of performance metrics Start replay

43 Benchmark Analysis Analysis = compare with Baseline Analysis tools:
RML Utilities SQLNexus ClearTrace Qure Analyzer

44 Demo QURE ANALYZER

45 Questions & Answers 9/10/2018 6:34 PM
© 2014 Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

46 Izpolnite anketo! Vam je bilo predavanje všeč?
Ste se naučili kaj novega? Vaše mnenje nam veliko pomeni! Da bo NT konferenca prihodnje leto še boljša, vas prosimo, da izpolnite anketo o zadovoljstvu, ki jo najdete v svojem NTK spletnem profilu.

47 9/10/2018 6:34 PM © 2014 Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.


Download ppt "SQL Server Baselining, Benchmarking and Workload Analysis"

Similar presentations


Ads by Google