27
Module 8: Monitoring SQL Server for Performance

Module 8: Monitoring SQL Server for Performance. Overview Why to Monitor SQL Server Performance Monitoring and Tuning Tools for Monitoring SQL Server

Embed Size (px)

Citation preview

Page 1: Module 8: Monitoring SQL Server for Performance. Overview Why to Monitor SQL Server Performance Monitoring and Tuning Tools for Monitoring SQL Server

Module 8: Monitoring SQL Server for Performance

Page 2: Module 8: Monitoring SQL Server for Performance. Overview Why to Monitor SQL Server Performance Monitoring and Tuning Tools for Monitoring SQL Server

Overview

Why to Monitor SQL Server

Performance Monitoring and Tuning

Tools for Monitoring SQL Server

Common Monitoring and Tuning Tasks

Page 3: Module 8: Monitoring SQL Server for Performance. Overview Why to Monitor SQL Server Performance Monitoring and Tuning Tools for Monitoring SQL Server

Why to Monitor SQL Server

Optimize the Business Application of SQL Server

Minimize the User or Query Response Time

Maximize the Throughput

Page 4: Module 8: Monitoring SQL Server for Performance. Overview Why to Monitor SQL Server Performance Monitoring and Tuning Tools for Monitoring SQL Server

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

Page 5: Module 8: Monitoring SQL Server for Performance. Overview Why to Monitor SQL Server Performance Monitoring and Tuning Tools for Monitoring SQL Server

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

Page 6: Module 8: Monitoring SQL Server for Performance. Overview Why to Monitor SQL Server Performance Monitoring and Tuning Tools for Monitoring SQL Server

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

Page 7: Module 8: Monitoring SQL Server for Performance. Overview Why to Monitor SQL Server Performance Monitoring and Tuning Tools for Monitoring SQL Server

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

Page 8: Module 8: Monitoring SQL Server for Performance. Overview Why to Monitor SQL Server Performance Monitoring and Tuning Tools for Monitoring SQL Server

Establishing a Performance Baseline

SQLServerSQLServer

WorkloadWorkload

ThroughputThroughput

SystemResources

SystemResources

OptimizationOptimization

ContentionContention

Page 9: Module 8: Monitoring SQL Server for Performance. Overview Why to Monitor SQL Server Performance Monitoring and Tuning Tools for Monitoring SQL Server

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

Page 10: Module 8: Monitoring SQL Server for Performance. Overview Why to Monitor SQL Server Performance Monitoring and Tuning Tools for Monitoring SQL Server

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

Page 11: Module 8: Monitoring SQL Server for Performance. Overview Why to Monitor SQL Server Performance Monitoring and Tuning Tools for Monitoring SQL Server

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

Page 12: Module 8: Monitoring SQL Server for Performance. Overview Why to Monitor SQL Server Performance Monitoring and Tuning Tools for Monitoring SQL Server

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

Page 13: Module 8: Monitoring SQL Server for Performance. Overview Why to Monitor SQL Server Performance Monitoring and Tuning Tools for Monitoring SQL Server

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

Page 14: Module 8: Monitoring SQL Server for Performance. Overview Why to Monitor SQL Server Performance Monitoring and Tuning Tools for Monitoring SQL Server

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

Page 15: Module 8: Monitoring SQL Server for Performance. Overview Why to Monitor SQL Server Performance Monitoring and Tuning Tools for Monitoring SQL Server

Transact-SQL Tools

System Stored Procedures

Global Variables

Transact-SQL Statements

DBCC Statements

Trace Flags

Page 16: Module 8: Monitoring SQL Server for Performance. Overview Why to Monitor SQL Server Performance Monitoring and Tuning Tools for Monitoring SQL Server

SQL Profiler

Trace and Capture Server Activity

Choose events to monitor

Choose trace criteria

Choose what data to capture

Group data meaningfully

Page 17: Module 8: Monitoring SQL Server for Performance. Overview Why to Monitor SQL Server Performance Monitoring and Tuning Tools for Monitoring SQL Server

Demonstration: Using SQL Profiler

Page 18: Module 8: Monitoring SQL Server for Performance. Overview Why to Monitor SQL Server Performance Monitoring and Tuning Tools for Monitoring SQL Server

SQL Query Analyzer

Show Query Execution Plan

Show Server Trace

Show Server-Side Statistics

Show Client-Side Statistics

Index Tuning Wizard

Page 19: 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

Monitoring Memory Use

Monitoring Threads and Processor Use

Monitoring Hard Disk I/O

Monitoring Locks

Monitoring for Poorly Performing Queries

Page 20: Module 8: Monitoring SQL Server for Performance. Overview Why to Monitor SQL Server Performance Monitoring and Tuning Tools for Monitoring SQL Server

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

Page 21: Module 8: Monitoring SQL Server for Performance. Overview Why to Monitor SQL Server Performance Monitoring and Tuning Tools for Monitoring SQL Server

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

Page 22: Module 8: Monitoring SQL Server for Performance. Overview Why to Monitor SQL Server Performance Monitoring and Tuning Tools for Monitoring 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

Page 23: Module 8: Monitoring SQL Server for Performance. Overview Why to Monitor SQL Server Performance Monitoring and Tuning Tools for Monitoring SQL Server

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

Page 24: Module 8: Monitoring SQL Server for Performance. Overview Why to Monitor SQL Server Performance Monitoring and Tuning Tools for Monitoring SQL Server

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

Page 25: Module 8: Monitoring SQL Server for Performance. Overview Why to Monitor SQL Server Performance Monitoring and Tuning Tools for Monitoring SQL Server

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

Page 26: Module 8: Monitoring SQL Server for Performance. Overview Why to Monitor SQL Server Performance Monitoring and Tuning Tools for Monitoring SQL Server

Lab A: Monitoring SQL Server

Page 27: Module 8: Monitoring SQL Server for Performance. Overview Why to Monitor SQL Server Performance Monitoring and Tuning Tools for Monitoring SQL Server

Review

Why to Monitor SQL Server

Performance Monitoring and Tuning

Tools for Monitoring SQL Server

Common Monitoring and Tuning Tasks