Академический Документы
Профессиональный Документы
Культура Документы
• 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.
Blocked:
IDENTIFY BLOCKING ISSUES
Way to reduce the blocking:
• RPC:Completed
• SP:StmtCompleted
• SQL:BatchStarting
• SQL:BatchCompleted
• Showplan XML
ANALYZING PERFORMANCE ISSUES
ANALYZING PERFORMANCE ISSUES
• Execution Warnings
• Sort Warnings
• Server Memory Change
DATABASE TUNING ADVISOR
Questions?