Top Banner
Module 8: Monitoring SQL Server for Performance
27

08. Monitoring SQL Server for Performance

May 25, 2017

Download

Documents

Kunal Puri
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: 08. Monitoring SQL Server for Performance

Module 8: Monitoring SQL Server for Performance

Page 2: 08. 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

Page 3: 08. Monitoring SQL Server for Performance

Why to Monitor SQL Server

Optimize the Business Application of SQL Server Minimize the User or Query Response Time Maximize the Throughput

Page 4: 08. Monitoring SQL Server for Performance

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: 08. Monitoring SQL Server for Performance

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: 08. Monitoring SQL Server for Performance

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: 08. Monitoring SQL Server for Performance

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: 08. Monitoring SQL Server for Performance

Establishing a Performance Baseline

SQLServer

Workload

Throughput

SystemResources

Optimization

Contention

Page 9: 08. Monitoring SQL Server for Performance

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: 08. Monitoring SQL Server for Performance

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: 08. Monitoring SQL Server for 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

Page 12: 08. Monitoring SQL Server for Performance

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: 08. Monitoring SQL Server for Performance

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: 08. Monitoring SQL Server for Performance

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: 08. Monitoring SQL Server for Performance

Transact-SQL Tools

System Stored Procedures Global Variables Transact-SQL Statements DBCC Statements Trace Flags

Page 16: 08. Monitoring SQL Server for Performance

SQL Profiler

Trace and Capture Server Activity Choose events to monitor

Choose trace criteria

Choose what data to capture

Group data meaningfully

Page 17: 08. Monitoring SQL Server for Performance

Demonstration: Using SQL Profiler

Page 18: 08. Monitoring SQL Server for Performance

SQL Query Analyzer

Show Query Execution Plan Show Server Trace Show Server-Side Statistics Show Client-Side Statistics Index Tuning Wizard

Page 19: 08. Monitoring SQL Server for Performance

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: 08. Monitoring SQL Server for Performance

Monitoring Memory Use

MemoryMemoryandandPagingPagingFileFileUseUse

Object: CounterObject: Counter GuidelineGuidelineMemory: Available Bytes This counter should be greater than

5,000 KB

Memory: Pages/sec This 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: 08. Monitoring SQL Server for Performance

Monitoring Threads and Processor Use

Object:Object: CounterCounter GuidelineGuideline

Processor: %Processor Time This counter should usually be less than 90 percent

System: 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

System: Processor Queue Length This counter should never be consistently greater than 2

Processor: %Privileged Time This counter should be as low as possible

Processor: %User Time This counter gives the percentage of time executing user processes such as SQL Server

Page 22: 08. Monitoring SQL Server for Performance

Monitoring Hard Disk I/O

Object: CounterObject: Counter GuidelineGuideline

PhysicalDisk: %Disk Time This counter should be consistently less than 90 percent

PhysicalDisk: Avg.Disk Queue Length

This counter should be no more than 2 times the number of spindles

PhysicalDisk: Disk Reads/sec This counter should be consistently less than the capacity of your hard disk subsystem

PhysicalDisk: Disk Writes/sec This counter should be consistently less than the capacity of your hard disk subsystem

Page 23: 08. Monitoring SQL Server for Performance

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: 08. Monitoring SQL Server for Performance

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: 08. Monitoring SQL Server for Performance

Recommended Practices

Establish a Performance Baseline

Monitor Actual Performance

Identify Performance Bottlenecks

Use the Appropriate Tools

Page 26: 08. Monitoring SQL Server for Performance

Lab A: Monitoring SQL Server

Page 27: 08. Monitoring SQL Server for Performance

Review

Why to Monitor SQL Server Performance Monitoring and Tuning Tools for Monitoring SQL Server Common Monitoring and Tuning Tasks