Top Banner
Resource Governor, Monitoring and Tracing On SQL Server
24

Resource Governor, Monitoring and Tracingsiret.ms.mff.cuni.cz/hoksza/teaching/mff/ndbi039/2011... · 2011. 12. 7. · Using SQL Trace through T-SQL • Create a trace by using sp_trace_create.

Feb 05, 2021

Download

Documents

dariahiddleston
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
  • Resource Governor, Monitoring and Tracing

    On SQL Server

  • Outline

    • Resource Governor

    – Why use RG?

    – Resource pooling

    • Monitoring

    – Activity monitor

    – Underlying DMVs

    • Tracing

    – How tracing works

  • What is Resource Governor?

    • New feature in SQL Server 2008

    • Helps you to manage SQL Server workload and system resource consumption

    • Enables placing limits on CPU or memory usage per incoming application request.

    • Only available in Enterprise or Developer editions (incl. all evaluation versions)

  • What is Resource Governor?

    • SQL Server 2008 provides Resource Governor, a feature than you can use to manage SQL Server workload and system resource consumption.

    • Resource Governor enables you to specify limits on the amount of CPU and memory that incoming application requests can use.

  • Reasons Behind Resource Governor

    • To place limits on resources:

    – Threads

    – CPU(s)

    – Memory

    • To have more control over database server.

    • To monitor “run-away” queries.

  • Workload Groups & Classifier

    • Ability to differentiate workloads (login, reports, calculations) with importance labels (low, medium, high).

    • Limits on:

    – Max memory/CPU and timeouts

    – Max DOP, max group requests

    • Classifier - user-defined function for implementing classification rules.

  • Resource Pools

    • Resource pool: A virtual subset of physical database engine resources.

    • You can think of a pool as a virtual SQL Server instance inside of a SQL Server instance.

    • Provides controls to specify – Min/Max Memory %

    – Min/Max CPU %

    – Max DOP

    • Workloads are mapped to resource pools N:1.

  • Resource Governor Schema

  • Resource Governor Commands

    • Enabling or disabling Resource Governor

    • Resource Pool and Workload Group creation

  • Classifier Function Example

  • Monitoring Resource Governor

    • Metadata CVs:

    – sys.resource_governor_resource_pools

    – sys.resource_governor_workload_groups

    – sys.resource_governor_configuration

    • Running value DMVs:

    – sys.dm_resource_governor_resource_pools

    – sys.dm_resource_governor_workload_groups

  • Activity Monitor

  • Activity Monitor

    • Overview

    • Active User Tasks

    – Shows information for active user connections to the instance. You can also run profiler from here for a particular process.

    • Resource Waits

    • Data File I/O

    • Recent Expensive Queries

  • Activity Monitor

    • How to open AM?

    – CTRL+ALT+A.

    – Right-click the instance name, and then select Activity Monitor.

    – On the SQL Server Management Studio standard toolbar, click Activity Monitor.

  • Activity Monitor Underlying DMV

    • sys.dm_os_performance_counters

    • sys.dm_exec_sessions

    • sys.dm_exec_requests

    • sys.dm_os_wait_stats

    • sys.dm_os_waiting_tasks

    • sp_who2 [spid]

  • sp_who2

  • SQL Tracing

    • Common usages:

    – Workload analysis and replay

    – Deadlocked/blocked process analysis

  • SQL Tracing

    • Client-side trace using SQL Profiler

    – events are streamed from the server, over the network, to the Profiler

    • Server-side trace

    – using a number of SQL Trace system stored procedures

  • SQL Trace Terminology

    • The following terms describe the key concepts of SQL Trace. • Event

    – The occurrence of an action within an instance of the Microsoft SQL Server Database Engine.

    • Data column – An attribute of an event.

    • Event class – A type of event that can be traced. The event class contains all of the data

    columns that can be reported by an event.

    • Event category – A group of related event classes.

    • Trace (noun) – A collection of events and data returned by the Database Engine.

    • Trace (verb) – To collect and monitor events in an instance of SQL Server.

  • SQL Trace Terminology

    • Trace definition – A collection of event classes, data columns and filters that identify the

    types of events to be collected during a trace.

    • Filter – Criteria that limit the events that are collected in a trace.

    • Trace file – A file created when a trace is saved.

    • Template – In SQL Server Profiler, a file that defines the event classes and data

    columns to be collected in a trace.

    • Trace table – In SQL Server Profiler, a table that is created when a trace is saved to a

    table.

  • SQL Trace Architecture

  • SQL Server Profiler

  • Introducing SQL Server Profiler

    • Microsoft SQL Server Profiler is a graphical user interface to SQL

    • You can monitor a production environment to see which stored procedures are affecting performance by executing too slowly.

    • To run SQL Server Profiler, on the Start menu, point to All Programs, Microsoft SQL Server 2008, Performance Tools, and then click SQL Server Profiler.

  • Using SQL Trace through T-SQL

    • Create a trace by using sp_trace_create. • Add events with sp_trace_setevent. • (Optional) Set a filter with sp_trace_setfilter. • Start the trace with sp_trace_setstatus. • Stop the trace with sp_trace_setstatus. • Close the trace with sp_trace_setstatus.