Vous êtes sur la page 1sur 24

Creating a Performance Baseline

for SQL Server

Ron Johnson
Overview
Why bother?
Whats in it for me?
Contents of the performance baseline.
Collecting performance baseline metrics.
Putting it all together.

2
Creating a Performance Baseline for SQL Server - Copyright 2012, Ron Johnson
Why Create a Performance Baseline
Provides a quantified starting point for
optimization efforts.
Provides a point of reference for future
performance comparisons.
Documents the server.
Provides a reference point for capacity
planning.

3
Creating a Performance Baseline for SQL Server - Copyright 2012, Ron Johnson
DEMONSTRATION
The Goal

4
Creating a Performance Baseline for SQL Server - Copyright 2012, Ron Johnson
Information to Collect
Static Server Data
Database File Characteristics
IO
Memory
Processor
Wait Statistics
Query Responsiveness

5
Creating a Performance Baseline for SQL Server - Copyright 2012, Ron Johnson
PerfMon, Profiler, and DMVs
Performance Monitor (PerfMon) is provided
as a Windows Administrative tool
Exposes a vast number of system metrics.
Dynamic Management Views (DMVs) are
provided by SQL Server (since 9.x) exposing a
vast number of system metrics via T-SQL.
Profiler is a SQL Server performance tool
providing a real-time view of SQL Server
performance.

6
Creating a Performance Baseline for SQL Server - Copyright 2012, Ron Johnson
Dynamic Management Views
Technically, the collection of objects referenced in the sys schema that I
will be referring to as DMVs are correctly known as Dynamic Management
Objects (DMOs)
Not at all like the Distributed Management Object (DMO)
DMOs are a collection of COM objects that are designed for programming all aspects of
managing Microsoft SQL Server [BOL] (deprecated, thankfully)
DMVs are simply views (DMV) and table-valued functions (DMF) that
operate at the server and database levels
DMVs may be queried just like any other view or table-valued function
DMVs expose information collected internally by the SQL Server Engine
Some data is a snapshot while other data is cumulative (from last restart or
counter reset)
Theres a DMV for that!
CLR, IO, Mirroring, Replication, Service Broker, Server Broker, Full-Text Search,
Index, Transactions, SQL O/S, Resource Governor,

7
Creating a Performance Baseline for SQL Server - Copyright 2012, Ron Johnson
Staging the Data
Develop a standard intermediate raw data
storage technique.
MS-Excel provides heterogeneous data storage and
visualization options.
Backup and safeguard the raw data for future
reference.
Keep the data organized.
A picture is worth a thousand words.
Easily communicate performance data to users and
managers

8
Creating a Performance Baseline for SQL Server - Copyright 2012, Ron Johnson
Static Server Data
Server hardware and configuration
Processors
Memory
Instance configuration
Installed services
Configuration settings
Database option settings
Uses
XP_CMDSHELL SYSTEMINFO
SERVERPROPERTY
XP_REGREAD
SYS.CONFIGURATIONS
SYS.DATABASES

9
Creating a Performance Baseline for SQL Server - Copyright 2012, Ron Johnson
DEMONSTRATION
Collecting Static Information

10
Creating a Performance Baseline for SQL Server - Copyright 2012, Ron Johnson
Database File Characteristics
Storage management is a primary DBA
responsibility.
Data file size, growth, and storage utilization
efficiency provide insight for capacity planning.
IO latency by database and disk.
SYSFILES
DBCC SHOWFILESTATS
DBCC SQLPERF (LOGSPACE)
XP_FIXEDDRIVES
11
Creating a Performance Baseline for SQL Server - Copyright 2012, Ron Johnson
DEMONSTRATION
Collecting Database File Characteristics

12
Creating a Performance Baseline for SQL Server - Copyright 2012, Ron Johnson
Measuring IO Performance
SQL Server, as all DBMS, is IO intensive.
Overall performance is directly related to the performance of
the IO subsystem.
IO performance measures the time required to read and
write to a disk.
We will use the IO-related DMVs to establish a Performance
Baseline.
For more advanced performance issue resolution we might use
PerfMon and Profiler to collect the data then combine them
over a time interval.
DMV of interest
sys.dm_os_performance_counters
sys.dm_io_virtual_file_stats

13
Creating a Performance Baseline for SQL Server - Copyright 2012, Ron Johnson
DEMONSTRATION
Collecting IO Metrics

14
Creating a Performance Baseline for SQL Server - Copyright 2012, Ron Johnson
Measuring Memory Performance
SQL Server, as all DBMS, performance is directly related to
the amount of primary memory available to the process
Hot data resides in memory
Important metrics for the Performance Baseline
Total Server Memory
Available Server Memory
SQL Server Memory
Page Life Expectancy (PLE)
Buffer Cache Hit Ratio
Plan Cache Hit Ratio
DMV of interest
sys.dm_os_performance_counters

15
Creating a Performance Baseline for SQL Server - Copyright 2012, Ron Johnson
DEMONSTRATION
Collecting Memory Performance Metrics

16
Creating a Performance Baseline for SQL Server - Copyright 2012, Ron Johnson
Measuring Wait Statistics
What is SQL Server waiting for?
Locking
Deadlocks
Worker
Memory
IO
Other
CLR
Backup Processing
Parallelization
Counter is cumulative
Collect and compare metrics over a time interval
Clear counter with
DBCC SQLPERF (sys.dm_os_wait_stats,CLEAR)
DMVs of interest
sys.dm_os_performance_counters
sys.dm_os_wait_stats

17
Creating a Performance Baseline for SQL Server - Copyright 2012, Ron Johnson
DEMONSTRATION
Collecting Wait Statistics

18
Creating a Performance Baseline for SQL Server - Copyright 2012, Ron Johnson
Measuring Processor Performance
CPU utilization metrics
SQL Server Processor time
Batches per Second
Compilations per Second
Recompilations per Second
Processor Affinity
DMVs of interest
sys.dm_os_performance_counters
sys.dm_os_wait_stats
sys.dm_os_schedulers
19
Creating a Performance Baseline for SQL Server - Copyright 2012, Ron Johnson
DEMONSTRATION
Collecting Processor Performance Metrics

20
Creating a Performance Baseline for SQL Server - Copyright 2012, Ron Johnson
Measuring Query Performance
Profiler-included vs. custom templates
Use the Tuning template for baseline
Use SQL Server Agent to execute Profiler Trace
Writing T-SQL trace definition
Running trace as a recurrent job
Collecting and analyzing the data
DBA Performance database

21
Creating a Performance Baseline for SQL Server - Copyright 2012, Ron Johnson
DEMONSTRATION
Collecting Query Performance Metrics

22
Creating a Performance Baseline for SQL Server - Copyright 2012, Ron Johnson
Bringing it all Together
The Baseline Performance Assessment Report
Provides documentation of the current state of the server and
instance
Provides a reference point for future performance comparisons
and capacity planning
Provides a starting point for optimization efforts
Baseline Performance Assessment is not a SQL
Configuration and Performance Review (SQL-CPR).
Not intended to replace a thorough server and instance
performance review.
An opportunity to recommend server or instance
configuration changes
Backup and archive the raw data

23
Creating a Performance Baseline for SQL Server - Copyright 2012, Ron Johnson
Next Steps
If its not broken, then it doesnt need to be fixed.
At least for now.
Monitor performance regularly.
Maintain a performance database.
Resources
Script may be downloaded at
http://rjssqlservernotes.wordpress.com/
Related papers may be downloaded at
http://rjssqlservernotes.wordpress.com/papers/

24
Creating a Performance Baseline for SQL Server - Copyright 2012, Ron Johnson

Vous aimerez peut-être aussi