Professional Documents
Culture Documents
Server performance
monitoring - Part 1
Change Management
2
Agenda
Performance Monitoring
◦ Real Time Monitoring
◦ Performance Trending
◦ Blocking and Locking
◦ Long Running Queries
◦ Fragmentation
Automated Tools for Performance
Monitoring
Questions / Wrap Up
3
Approach
Data collection
◦ Profiler / Trace
◦ SSMS
◦ Performance Monitor
◦ DMVs
◦ Third Party Tools
Dataanalysis
Resolution
4
Real Time Monitoring - Problem
Scenario
◦ Everything has been running great, but all of
sudden the system slows down.
Why is this important
◦ Know what is happening now
◦ Look for things outside the norm
5
Real Time Monitoring - Solution
What to capture
◦ Counters
OS (CPU, memory, I/O, Network)
SQL (connections, transactions, memory usage)
◦ Current running processes
◦ Wait stats
6
Real Time Monitoring - Solution
Counters
◦ Performance Monitor
◦ Task Manager
Current processes
◦ sys.dm_exec_requests
◦ sp_who2
◦ Activity Monitor
◦ sys.sysprocesses
Wait stats
◦ sys.dm_os_waiting_tasks
◦ sys.dm_os_wait_stats
◦ DBCC SQLPERF ('sys.dm_os_wait_stats', CLEAR);
Other tools
◦ Filestats
◦ SSMS Reports
◦ Profiler or server side trace
Demo
7
Real Time Monitoring - Next Steps
Select the right tools
◦ Performance Counters
◦ Current Processes
◦ Wait Stats
Capture data and analyze
Determine whether system wide or
specific issue
This is just the start…
8
Real Time Monitoring – Tips
http://mssqltips.com/searchbytipid.asp
Tip IDs
◦ 1416
◦ 1265
◦ 1179
◦ 1067
9
Performance Trending - Problem
Scenario
◦ Your company is planning on acquiring new
business and your boss asks if there are
sufficient hardware and database resources.
Why it is important
◦ Get better handle on overall usage
◦ Plan for growth and tuning
10
Performance Trending - Solution
What to capture
◦ Counters
OS (CPU, memory, I/O, Network)
SQL (connections, transactions, memory usage)
◦ Current running processes
◦ Wait stats
◦ Growth stats using sp_spaceused for database, tables
◦ Traces
Create repository for trending
SSMS Reports
11
Performance Trending - Solution
How to do this
◦ Pick tools to use
◦ Create tables to store data
◦ Schedule tasks to run and load the data
◦ Create reports from collected data
Demo
◦ sp_spaceused
◦ SSMS Reports
12
Performance Trending - Next Steps
Determine what to capture
How often to capture data
What tools to use
Load into SQL Server for trending
Aggregate data
Analyze data with queries
Download SQL Server 2005 Performance
Dashboard Reports
Setup ongoing trace and PerfMon collection
Setup alerts
13
Performance Trending - Tips
http://mssqltips.com/searchbytipid.asp
Tip IDs
◦ 1475
◦ 1515
◦ 1575
◦ 1212
Other webcasts
◦ http://mssqltips.com/webcast2.asp?id=37
14
Blocking / Locking - Problem
Scenario
◦ You just rolled out some new code and users
are starting to complain that things are taking
forever to complete.
Why it is important
Slows things down
Can lead to a long trail of blocked processes
15
Blocking / Locking - Solution
What to capture
◦ Current running processes
◦ Lock information
◦ Lead blocker
◦ What statements are running
16
Blocking / Locking - Solution
◦ Current running processes
◦ sp_who2
◦ Activity Monitor
◦ sys.sysprocesses
◦ Lock Information
◦ sp_lock
◦ sys.dm_tran_locks
◦ Lead Blocker
◦ Lead blocker script
◦ SSMS Reports – “All Blocking Transactions”
◦ What statements are being run
◦ Use DBCC INPUTBUFFER
◦ sys.dm_exec_sql_text
◦ fn_get_sql
◦ Activity Monitor
Demo
17
Blocking / Locking - Next Steps
Modify code to keep transactions short
Use hints
Create new indexes or using covering indexes
Avoid doing maintenance tasks during peak times
Automate collection of blocking data
Use SSMS Reports
Use of Isolation Levels
Separate reporting and transactions
Minimize compiles and recompiles
Automate capture of blocking data
http://support.microsoft.com/kb/271509
Last resort using the KILL command
18
Blocking / Locking - Tips
http://mssqltips.com/searchbytipid.asp
Tip IDs
◦ 1485
◦ 1257
◦ 1359
◦ 1501
19
Long Running Queries - Problem
Scenario
◦ You’ve fixed all the known issues, you want to
be proactive, now what?
Why it is important
◦ Hog system resources
◦ Identify inefficient code
◦ Improve overall performance
20
Long Running Queries - Solution
What to capture
◦ Identify Long Running Queries
◦ Execution Plans
◦ Query Stats
21
Long Running Queries - Solution
Identify
◦ Profiler
◦ Server side trace
◦ SSMS Reports
Execution Plans
Review execution plans
Index usage
Query Stats
◦ Statistics Time
◦ Statistics I/O
◦ WAIT STATS
Demo
22
Long Running Queries - Next Steps
UseDatabase Tuning Advisor
Make changes
◦ Create new indexes
◦ Rewrite queries
◦ Simplify queries
◦ Do not use views upon views
◦ Use EXISTS vs IN
◦ Limit scope of data returned, less columns and
less rows
23
Long Running Queries - Tips
http://mssqltips.com/searchbytipid.asp
Tip IDs
◦ 1035
◦ 1212
◦ 1239
◦ 1545
◦ 1642
24
Fragmentation - Problem
Scenario
◦ This same report has been running for years,
but the users keep complaining it is getting
slower and slower and slower.
Why it is important
◦ Slows down performance
◦ Waste of space
◦ Extra work for SQL Server
25
Fragmentation - Solution
What to capture
◦ Fragmentation information
◦ Auto Grow and Auto Shrink data
◦ OS file fragmentation
26
Fragmentation - Solution
How to do this
◦ DBCC SHOWCONTIG
◦ sys.dm_db_index_physical_stats
◦ sp_spaceused
◦ SQL Server Management Studio
Demo
27
Fragmentation - Next Steps
Gather data
Analyze data
Rebuilds vs Reorganize
Maintenance plans
Selective rebuilds
Use correct fill factors
28
Fragmentation - Tips
http://mssqltips.com/searchbytipid.asp
Tip IDs
◦ 1481
◦ 1165
◦ 1014
◦ 1367
◦ 1339
◦ 1018
29
Monitoring Using Other Tools
Idera SQL diagnostic manager
Real Time Monitoring
Performance Trending
Blocking and Locking
Long Running Queries
Fragmentation
30
Questions and Wrap-up
Thanks to our sponsor: Idera
Next webcast in the series: March 4th, 2009,
4pm EST
Special offer for webcast attendees:
◦ Purchase SQL diagnostic manager before March 31st
and get the SQL admin toolset for free (regular price
$495)
◦ SQL admin toolset provides 24 essential tools for
administering SQL Server – reduce routine tasks from
hours to minutes!
Visit www.idera.com to download a free 14-day
trial of any Idera product
31