Module 8: Monitoring SQL Server for Performance
Dec 23, 2015
Module 8: Monitoring SQL Server for Performance
Overview
Why to Monitor SQL Server
Performance Monitoring and Tuning
Tools for Monitoring SQL Server
Common Monitoring and Tuning Tasks
Why to Monitor SQL Server
Optimize the Business Application of SQL Server
Minimize the User or Query Response Time
Maximize the Throughput
Performance Monitoring and Tuning
Strategies for Performance Tuning
Selecting an Approach to Performance Tuning
Developing a Performance Tuning Methodology
Establishing a Performance Baseline
Detecting Performance Bottlenecks
Common Monitoring Tasks
Strategies for Performance Tuning
Optimizing the Response Time
Requires knowledge of the application, the environment, and the users
Optimizing the Throughput
Requires knowledge of how SQL Server handles data access, concurrency, and interaction with Windows 2000
Selecting an Approach to Performance Tuning
Approach Optimization for Application Response Time and Server Throughput by:
Tuning the client application
Tuning the database
Tuning SQL Server
Tuning the hardware configuration
Developing a Performance Tuning Methodology
Design for Performance
Know the user requirements
Know the data
Design appropriately
Plan for Performance
Define the parameters
Set performance goals
Measure and document actions and results
Establishing a Performance Baseline
SQLServerSQLServer
WorkloadWorkload
ThroughputThroughput
SystemResources
SystemResources
OptimizationOptimization
ContentionContention
Detecting Performance Bottlenecks
Decide What to Examine
Memory, CPU use, disk I/O, user connection, and locks
Know the Acceptable Range
Extremes above or below the baseline may indicate bottlenecks
Common Monitoring Tasks
SQL Query Analyzer
Windows 2000 Event Viewer
Windows System Monitor
Current Activity window in SQL Server Enterprise Manager
Transact-SQL
SQL Profiler
System-Level Monitoring
Hardware
Operating system
Application
SQL Server-Specific Monitoring
SQL Server activity
Data consistency
Specific Query Performance
Tools for Monitoring SQL Server
Windows 2000 Event Viewer
Windows System Monitor with SQL Server
Current Activity Window in SQL Server Enterprise Manager
Transact-SQL Tools
SQL Profiler
SQL Query Analyzer
Windows 2000 Event Viewer
Windows 2000 Event Viewer Displays Error, Warning, and Informational Messages
Windows 2000 Event Viewer Allows You to View Windows Event Logs
Windows application log
Windows system log
Windows security log
Windows System Monitor with SQL Server
Windows System Monitor Can Track:
SQL Server I/O
SQL Server memory usage
SQL Server user connections
SQL Server locking
Replication activity
Current Activity Window in SQL Server Enterprise Manager
SQL Server Process Information
View by process ID
View by object
Locks, Blocking, and Deadlocks
Managing Locks and Processes
System administrators can take actions to inform users or terminate processes
Transact-SQL Tools
System Stored Procedures
Global Variables
Transact-SQL Statements
DBCC Statements
Trace Flags
SQL Profiler
Trace and Capture Server Activity
Choose events to monitor
Choose trace criteria
Choose what data to capture
Group data meaningfully
Demonstration: Using SQL Profiler
SQL Query Analyzer
Show Query Execution Plan
Show Server Trace
Show Server-Side Statistics
Show Client-Side Statistics
Index Tuning Wizard
Common Monitoring and Tuning Tasks
Monitoring Memory Use
Monitoring Threads and Processor Use
Monitoring Hard Disk I/O
Monitoring Locks
Monitoring for Poorly Performing Queries
Monitoring Memory Use
MemoryMemoryandandPagingPagingFileFileUseUse
Object: CounterObject: Counter GuidelineGuideline
Memory: Available Bytes This counter should be greater than 5,000 KB
Memory: Pages/secThis counter should never be consistently greater than zero
Process: Page Faults/sec A high number indicates excessivepaging
MemoryMemoryand and Buffer Buffer UseUse
Object:Object: CounterCounter GuidelineGuideline
Process: Working Set This counter should be greater than 5,000 KB
SQL Server: Buffer Manager: Buffer Cache Hit Ratio
This counter should be greater than 90 percent
SQL Server: Buffer Manager: Total Pages
A low number may indicate frequent disk I/O, more memory may be required
SQL Server: Memory Manager: Total Server Memory
If this counter is consistently close to the amount of physical memory, more memory may be required
Monitoring Threads and Processor Use
Object:Object: CounterCounterObject:Object: CounterCounter GuidelineGuidelineGuidelineGuideline
Processor: %Processor TimeProcessor: %Processor Time This counter should usually be less than 90 percentThis counter should usually be less than 90 percent
System: Context Switches/SecSystem: Context Switches/Sec
On a multiprocessor computer, if this counter reaches 8000, and the Processor: % Processor Time counter is over 90 percent, consider enabling SQL Server fiber mode scheduling
On a multiprocessor computer, if this counter reaches 8000, and the Processor: % Processor Time counter is over 90 percent, consider enabling SQL Server fiber mode scheduling
System: Processor Queue LengthSystem: Processor Queue Length This counter should never be consistently greater than 2This counter should never be consistently greater than 2
Processor: %Privileged TimeProcessor: %Privileged Time This counter should be as low as possibleThis counter should be as low as possible
Processor: %User TimeProcessor: %User Time This counter gives the percentage of time executing user processes such as SQL ServerThis counter gives the percentage of time executing user processes such as SQL Server
Monitoring Hard Disk I/O
Object: CounterObject: CounterObject: CounterObject: Counter GuidelineGuidelineGuidelineGuideline
PhysicalDisk: %Disk TimePhysicalDisk: %Disk Time This counter should be consistently less than 90 percentThis counter should be consistently less than 90 percent
PhysicalDisk: Avg.Disk Queue Length
PhysicalDisk: Avg.Disk Queue Length
This counter should be no more than 2 times the number of spindlesThis counter should be no more than 2 times the number of spindles
PhysicalDisk: Disk Reads/secPhysicalDisk: Disk Reads/sec This counter should be consistently less than the capacity of your hard disk subsystemThis counter should be consistently less than the capacity of your hard disk subsystem
PhysicalDisk: Disk Writes/secPhysicalDisk: Disk Writes/sec This counter should be consistently less than the capacity of your hard disk subsystemThis counter should be consistently less than the capacity of your hard disk subsystem
Monitoring Locks
Deadlocks
Automatically detected and killed
Blocking Locks
Administrator intervention required
Managing Locks
Windows System Monitor, SQL Profiler, SQL Server Enterprise Manager, and stored procedures
Monitoring for Poorly Performing Queries
Identifying Query Performance
SQL Profiler, traces, and stored procedures
Causes of Poor Query Performance
Network, memory, statistics, indexes, and query structure
Recommended Practices
Establish a Performance BaselineEstablish a Performance Baseline
Monitor Actual PerformanceMonitor Actual Performance
Identify Performance BottlenecksIdentify Performance Bottlenecks
Use the Appropriate ToolsUse the Appropriate Tools
Lab A: Monitoring SQL Server
Review
Why to Monitor SQL Server
Performance Monitoring and Tuning
Tools for Monitoring SQL Server
Common Monitoring and Tuning Tasks