Вы находитесь на странице: 1из 22

SQL PROFILER - 2

• Identifying and analyzing the Deadlocks


• Identify Blocking issues and creating Blocked process report
• Analyzing Performance issues
• Database tuning Advisor
DEADLOCK

• Example:
spid101 spid102
TRACE DEADLOCKS
The events you might consider collecting include:

• Deadlock graph
• Lock: Deadlock
• Lock: Deadlock Chain
• RPC:Completed
• SP:StmtCompleted
• SQL:BatchCompleted
• SQL:BatchStarting
TRACE DEADLOCKS
SELECTING DATA COLUMNS

• EventClass
• TextData
• ApplicationName
• DatabaseName
• ServerName
• SessionLoginName
• SPID
• LoginName
• EventSequence
TRACE DEADLOCKS
Trace Properties
TRACE DEADLOCKS
Deadlock Trace Sample:
TRACE DEADLOCKS
Deadlock Graph:
TRACE DEADLOCKS
Prevent or Reduce Deadlocks:
• Database design is properly normalized.
• Application access database objects in the same order every time.
• Keep transactions as short as possible.
• Avoid cursors where ever possible.
• Consider reducing lock escalation by using the ROWLOCK or PAGLOCK.
• Consider using the NOLOCK hint to prevent locking in case of reports.
• Check SQL statements plans to use indexes and amount of data retrieved.
IDENTIFY BLOCKING ISSUES
Blocking occurs when one SPID holds a lock on a specific resource
and a second SPID attempts to acquire a conflicting lock type on the
same resource.

• sp_who or sp_who2 displays the blocking/blocked spid


• SQL Profiler Event – Blocked Process Report
IDENTIFY BLOCKING ISSUES
SQL Profiler Event
IDENTIFY BLOCKING ISSUES
SELECTING DATA COLUMNS
• Events
• TextData
• Duration
• IndexID
• Mode
• LoginSid
• DatabaseID
• ServerName
• EndTime
IDENTIFY BLOCKING ISSUES
Blocked
Process
Report:
IDENTIFY BLOCKING ISSUES
Blocker:

Blocked:
IDENTIFY BLOCKING ISSUES
Way to reduce the blocking:

• Identify problematic code and rewrite it.


• Ensure that all transactions are as short as possible.
• Only return the absolutely minimum amount of data needed.
• Identify and add missing indexes.
• Ensure column and index statistics are kept current.
• Use hints to modify locking behavior.
ANALYZING PERFORMANCE ISSUES

Identify Slow running queries capture the following events:

• RPC:Completed
• SP:StmtCompleted
• SQL:BatchStarting
• SQL:BatchCompleted
• Showplan XML
ANALYZING PERFORMANCE ISSUES
ANALYZING PERFORMANCE ISSUES

Identify Excessive AUTO STATS Activity

AUTO_UPDATE_STATISTICS database option, which is turned on by


default.
ANALYZING PERFORMANCE ISSUES

Identify Excessive Database File Growth/Shrinkage


ANALYZING PERFORMANCE ISSUES

Selecting the Data Columns:


• EventClass
• EventSubClass
• TextData
• Duration
• IntegerData
• ApplicationName
• DatabaseName
• LoginName
• ServerName
• SPID
• StartTime
ANALYZING PERFORMANCE ISSUES

Identify Memory Problems:

• Execution Warnings
• Sort Warnings
• Server Memory Change
DATABASE TUNING ADVISOR

For analyzing required indexes, statistics, partitioning, strategy and


physical design structure for performance improvement.
SQL PROFILER

Questions?

Вам также может понравиться