PERFORMANCE TUNING FOR
PIRATES!

John Sterrett (@JohnSterrett)
HTTP://JOHNSTERRETT.COM/GO/PERFORMANCE
ABOUT John…

I am a Remote DBA Expert
• Responsible 100+ Instances of SQL Server
• Senior DBA on Integration Team
Mid-Atlantic Region Mentor
Founder of WVPASS (SQL UG)
Host of SQL Saturday #36 and #80
I reside in Wheeling, WV (Pittsburgh, PA)




                                             2
Pirates and Yankees




Photos: http://www.flickr.com/photos/jaubele1/4299542394/ and http://www.flickr.com/photos/wenzday01/2537854102

                                                                                                                  3
Objectives

•   Eliminate the Obvious
•   Know the process
•   Know the common bottlenecks
•   Know your Tools
    –   Wait Stats
    –   Performance Monitor & PAL (WMI Counters)
    –   DMV’s and scripts
    –   SQL Server Side Trace (SQL Profiler)
    –   Clear Trace
    –   SQL Diag
    –   SQL Nexus
    –   RML Utilities
        •   ReadTrace
        •   Ostress
• Know where to go for help...

                                                   4
Eliminate the Obvious




                        5
Eliminate the OBVIOUS




    http://theiphonefever.blogspot.com/2010/10/movies-you-should-watch-office-space.html

                                                                                           6
Know the process!


                   Generate
                   workload



          Make                Capture
         Changes              workload



                    Analyze
                   captured
                   workload


                                         7
12 Steps to workload Tuning




                              8
12 Steps to workload Tuning

1. Backup Production Database




                                9
12 Steps to workload Tuning

1. Backup Production Database
2. Capture Production Workload




                                 10
12 Steps to workload Tuning

1. Backup Production Database
2. Capture Production Workload
3. Analyze Workload and Script Changes (Don’t
   Implement)

  *** Done with Production ***




                                                11
12 Steps to workload Tuning

1. Backup Production Database
2. Capture Production Workload
3. Analyze Workload and Script Changes (Don’t
   Implement)
4. Restore Backup on Test Server




                                                12
12 Steps to workload Tuning

1. Backup Production Database
2. Capture Production Workload
3. Analyze Workload and Script Changes (Don’t
   Implement)
4. Restore Backup on Test Server
5. Prepare to capture Workload on Test Server




                                                13
12 Steps to workload Tuning

1. Backup Production Database
2. Capture Production Workload
3. Analyze Workload and Script Changes (Don’t
   Implement)
4. Restore Backup on Test Server
5. Prepare to capture Workload on Test Server
6. Replay Production Workload on Test Server




                                                14
12 Steps to workload Tuning

1. Backup Production Database
2. Capture Production Workload
3. Analyze Workload and Script Changes (Don’t
   Implement)
4. Restore Backup on Test Server
5. Prepare to capture Workload on Test Server
6. Replay Production Workload on Test Server
7. Analyze to Establish Baseline




                                                15
12 Steps to workload Tuning

1. Backup Production Database
2. Capture Production Workload
3. Analyze Workload and Script Changes (Don’t
   Implement)
4. Restore Backup on Test Server
5. Prepare to capture Workload on Test Server
6. Replay Production Workload on Test Server
7. Analyze to Establish Baseline
8. Restore Backup on Test Server


                                                16
12 Steps to workload Tuning

1. Backup Production Database
2. Capture Production Workload
3. Analyze Workload and Script Changes (Don’t
   Implement)
4. Restore Backup on Test Server
5. Prepare to capture Workload on Test Server
6. Replay Production Workload on Test Server
7. Analyze to Establish Baseline
8. Restore Backup on Test Server
9. Make Changes to Improve Performance on Test Server

                                               17
12 Steps to workload Tuning

1. Backup Production Database
2. Capture Production Workload
3. Analyze Workload and Script Changes (Don’t Implement)
4. Restore Backup on Test Server
5. Prepare to capture Workload on Test Server
6. Replay Production Workload on Test Server
7. Analyze to Establish Baseline
8. Restore Backup on Test Server
9. Make Changes to Improve Performance on Test Server
10. Prepare to Capture Production Workload on Test Server


                                                     18
12 Steps to workload Tuning

1. Backup Production Database
2. Capture Production Workload
3. Analyze Workload and Script Changes (Don’t Implement)
4. Restore Backup on Test Server
5. Prepare to capture Workload on Test Server
6. Replay Production Workload on Test Server
7. Analyze to Establish Baseline
8. Restore Backup on Test Server
9. Make Changes to Improve Performance on Test Server
10. Prepare to Capture Production Workload on Test Server
11. Replay Workload on Test Server

                                                     19
12 Steps to workload Tuning

1. Backup Production Database
2. Capture Production Workload
3. Analyze Workload and Script Changes (Don’t Implement)
4. Restore Backup on Test Server
5. Prepare to capture Workload on Test Server
6. Replay Production Workload on Test Server
7. Analyze to Establish Baseline
8. Restore Backup on Test Server
9. Make Changes to Improve Performance on Test Server
10. Prepare to Capture Production Workload on Test Server
11. Replay Workload on Test Server
12. Analyze and Compare Workload with Baseline
   *** Repeat Steps 8 to 12 as needed ***
                                                      20
Where can things Go wrong?




                             21
Meet the Bottlenecks




      MEMORY                                      DISK (SPINDLES)                                                        CPU




                    NETWORK                                  LOCKING, BLOCKING & DEADLOCKS
Photos: http://www.flickr.com/photos/kaiban/5159888367/lightbox/ and http://www.flickr.com/photos/moodog/504456253 and
http://www.flickr.com/photos/marksze/4231115464 and http://www.flickr.com/photos/vvvracer/5264339383 and
http://www.flickr.com/photos/iphil_photos/4962369046

                                                                                                                          22
3 Options To Resolve bottlenecks




                                   23
3 Options To Resolve bottlenecks



1. Reduce Workload




                                   24
3 Options To Resolve bottlenecks



1. Reduce Workload
2. Tune Workload to reduce bottleneck resource




                                                 25
3 Options To Resolve bottlenecks



1. Reduce Workload
2. Tune Workload to reduce bottleneck resource
3. Add additional Hardware




                                                 26
Viewing Wait Stats

• Sys.dm_os_wait_stats
• Wait stats can be cleared manually or during restart.
  – DBCC SQLPERF(‘sys.dm_os_wait_stats’, CLEAR)
• Focus on waits dedicated to bottlenecks




                                                     27
Common WAIT STATS

•   ASYNC_NETWORK_IO
•   LCK_M_*
•   IO_COMPLETION
•   PAGELATCH_* or PAGEIOLATCH_*
•   WRITELOG
•   CX_PACKET
•   SOS_SCHEDULER_YIELD




                                   28
DEMO!!!!




• Review Wait Statistics

                           29
Memory Performance counters


                                                         You Want    Description
Object                       Counter
                                                         > 256 MB    Unused physical memory
Memory                       Available Mbytes
                                                         < 10        Reads from hard disk per second to memory
Memory                       Pages Input/sec
                                                         > 300       On average, how many seconds SQL Server expects page to say in cache
                                                                     (memory)
SQL Server: Buffer Manager   Page Life Expectancy
                                                                     Shows amount of memory SQL Server is currently using.
SQL Server: Memory Manager   Total Server Memory (KB)
                                                                     Amount of memory that SQL Server wants to use based on configured max
                                                                     Server Memory setting
SQL Server: Memory Manager   Target Server Memory (KB)
                                                                    0 Total number of processess pers second waiting for workspace memory grants
SQL Server: Memory Manager   Memory Grants Pending
                                                         > 640       Total number of pages avaiable across all free lists. A value under 640
SQL Server: Buffer Manager   Free Pages
                                                         < 20        Number of times per second that the lazywritter process moves dirty page from
                                                                     buffer to disk.
SQL Server: Buffer Manager   LazyWrites/Sec




                                                                                                                                 30
Disk Performance Counters


     • The sys.dm_io_virtual_file_stats DMV can be used to get disk latency for
       individual sql server files.


Object          Counter              You Want   Description


                                                Avg. Disk sec/Read is the average time, in seconds, of a read of data from the disk.This
                                                analysis determines if any of the physical disks are responding slowly.


Physical Disk   Avg Disk Sec/Read    < 25ms
                                                Avg. Disk sec/Write is the average time, in seconds, of a write of data to the disk.

Physical Disk   Avg Disk Sec/Write   < 25ms
                                                Disk Reads/sec is the rate of read operations on the disk.
Physical Disk   Disk Reads/sec
                                                Disk Writes/sec is the rate of write operations on the disk.
Physical Disk   Disk Writes/sec




                                                                                                                             31
CPU Performance Counters




Object               Counter           You Want   Description


                                       < 80%      Percentage of processor time spent on SQL Server process threads.
Process (sqlservr)   %Processor Time
                                       < 80%      Percentage of elapsed time the processor spends executing non-idle threads.
Processor            %Processor Time




                                                                                                                                32
General Workload performance
 counters
Object                       Counter                   You Want                     Description

                                                                                    Number of SQL batch requests received by server. This counter
                                                                                    measures the number of batch requests that SQL Server receives per
                             Batch Requests/Sec                                     second, and generally follows in step to how busy your server's CPUs
SQL Server: SQL Statistics   (SQL2005/08)                                           are.
                                                       < 10% of the number of       Number of SQL compilations.
SQL Server: SQL Statistics   SQL Compilations/sec      batch request/sec
                                                       < 10% of the number of       Number of SQL re-compiles. This needs to be 0 as much as possible. A
                                                       compilations/sec             recompile can cause deadlocks and compile locks that are not
SQL Server: SQL Statistics   SQL Re-Compilations/sec                                compatible with any locking type.

SQL Server: SQL Statistics   User Connections
                                                       1 Full scan for every 1000   This counter monitors the number of full scans on base tables or
                                                       index searches               indexes. High values indicate that we may be having performance
SQL Server: Access Methods Full Scans/sec                                           issues due to table / index page scans.
                                                                                    This counter measures the number of index searches per second. Index
                                                                                    searches are used to start range scans, single index record fetches, and
                                                                                    to reposition within an index. Index searches are preferable to index
SQL Server: Access Methods Index Searches/sec                                       and table scans.
                                                                                    Number of page splits per second that occur as a result of overflowing
                                                                                    index pages. Reduce non-sequential inserts or use fill factor and
SQL Server: Access Methods Page Splits/sec                                          pad_index to leave more empty space per page.




                                                                                                                                        33
Locking Performance Counters



Object                           Counter                      You Want   Description


                                                                         Number of lock requests per second
SQL Server: Locks                Number of Deadlocks/sec      <1         that resulted in deadlock.
                                                                         Number of times SQL escalated
                                                                         locks to table level. This can indicate
SQL Server: Locks                Table Lock Escalations/sec              poorly coded transactions.
                                                                         The average wait time for each lock
SQL Server: Locks                Avg Wait Time (ms)           < 500      request that had to wait.
                                                                         Number of currently blocked
SQL Server: General Statistics   Processes blocked                       processes.




                                                                                           34
DEMO!!!




• Review Perfmon
• Review PAL Tool
 – Collection Process
 – Generating Reports
 – Reviewing Reports
                        35
Execution DMV’s

• Sys.dm_exec_session
 – Returns one row per authenticated session, including user and
   system processes.
• Sys.dm_exec_requests
 – Returns one row for each request executing within SQL Server,
   doesn’t include code executed outside of SQL (distributed queries,
   extended stored procedures etc…)
• Sys.dm_exec_query_stats
 – Returns one row per query statement with cached plan, detailing
   aggregated performance stats for cached plans.
• Sys.dm_exec_connections
 – Returns server information about a connection to SQL Server
   including client network address, TCP Port etc..

                                                             36
Query details DMV’S

• Sys.dm_exec_sql_text
 – Returns the text of the SQL Server batch that is identified by
   specific sql handle.
• Sys.dm_exec_text_query_plan
 – Returns the showplan output in text format.
• Sys.dm_query_plan
 – Returns a given query’s showplan output in xml.




                                                               37
INDEX DMV’s

• Sys.dm_db_index_usage_stats
 – Returns a count of index operations including seeks, scans, lookup
   and updates
• Sys.dm_db_index_physical_stats
 – Returns size and fragmentation information for data pages and
   indexes.
• DMV’s to find recommended indexes
 –   Sys.dm_db_missing_index_columns
 –   Sys.dm_db_missing_index_details
 –   Sys.dm_db_missing_index_groups
 –   Sys.dm_db_missing_index_group_stats


                                                            38
SQLOS DMV’s

• Sys.dm_os_sys_memory
 – Returns complete picture of memory at the os level including total and
   available memory.
• Sys.dm_os_tasks
 – Returns a row for each OS task thais is active in the instance of SQL
   Server.
• Sys.dm_os_threads
 – Returns a row for each SQLOS thread running under the SQL Server
   process.
• Sys.dm_os_performance_counters
 – Returns a row for each SQL Server perfmon counter.
• Sys.dm_os_waiting_tasks
 – Returns information about the wait queue of SQLOS. This would be
   tasks waiting on resources like blocking and latch contention etc..

                                                                 39
DMV Queries (DEMO)




      http://www.flickr.com/photos/democonference/4458079104
• What is Running?
• Probing the Proc Cache

                                                               40
SQL Profiler (DEMO!)




      http://www.flickr.com/photos/democonference/4458079104
• Generate Server Side traces
 – Tuning Columns and Events
 – Remove the noise
• Read Trace with Clear Trace
                                                               41
SQL Diag (DEMO)




     http://www.flickr.com/photos/democonference/4458079104
• Review SQL Diag
• Review PerStats Scripts
• Collect perfmon, sql trace, blocking and more…
                                                              42
SQL NEXUS (DEMO)




       http://www.flickr.com/photos/democonference/4458079104
• Import SQLDiag
• Analysis collected data

                                                                43
RML Utilities (DEMO)




      http://www.flickr.com/photos/democonference/4458079104

• Ostress (Replay)
• ReadTrace (Compare Workload to Baseline)
                                                               44
Help I need Some One!!!!

• Performance Virtual Chapter
  – http://performance.sqlpass.org/
• Twitter (#sqlhelp)
• Message boards
  – www.sqlservercentral.com
  – www.msdn.com
• Blogs
• Consultants




                                      45
Where to go next?

• HTTP://JOHNSTERRETT.COM/GO/PERFORMANCE
 – Videos
 – Reference Links
 – Slides




                                     46
Thank You to our Sponsors

Performance Tuning for Pirates!

  • 1.
    PERFORMANCE TUNING FOR PIRATES! JohnSterrett (@JohnSterrett) HTTP://JOHNSTERRETT.COM/GO/PERFORMANCE
  • 2.
    ABOUT John… I ama Remote DBA Expert • Responsible 100+ Instances of SQL Server • Senior DBA on Integration Team Mid-Atlantic Region Mentor Founder of WVPASS (SQL UG) Host of SQL Saturday #36 and #80 I reside in Wheeling, WV (Pittsburgh, PA) 2
  • 3.
    Pirates and Yankees Photos:http://www.flickr.com/photos/jaubele1/4299542394/ and http://www.flickr.com/photos/wenzday01/2537854102 3
  • 4.
    Objectives • Eliminate the Obvious • Know the process • Know the common bottlenecks • Know your Tools – Wait Stats – Performance Monitor & PAL (WMI Counters) – DMV’s and scripts – SQL Server Side Trace (SQL Profiler) – Clear Trace – SQL Diag – SQL Nexus – RML Utilities • ReadTrace • Ostress • Know where to go for help... 4
  • 5.
  • 6.
    Eliminate the OBVIOUS http://theiphonefever.blogspot.com/2010/10/movies-you-should-watch-office-space.html 6
  • 7.
    Know the process! Generate workload Make Capture Changes workload Analyze captured workload 7
  • 8.
    12 Steps toworkload Tuning 8
  • 9.
    12 Steps toworkload Tuning 1. Backup Production Database 9
  • 10.
    12 Steps toworkload Tuning 1. Backup Production Database 2. Capture Production Workload 10
  • 11.
    12 Steps toworkload Tuning 1. Backup Production Database 2. Capture Production Workload 3. Analyze Workload and Script Changes (Don’t Implement) *** Done with Production *** 11
  • 12.
    12 Steps toworkload Tuning 1. Backup Production Database 2. Capture Production Workload 3. Analyze Workload and Script Changes (Don’t Implement) 4. Restore Backup on Test Server 12
  • 13.
    12 Steps toworkload Tuning 1. Backup Production Database 2. Capture Production Workload 3. Analyze Workload and Script Changes (Don’t Implement) 4. Restore Backup on Test Server 5. Prepare to capture Workload on Test Server 13
  • 14.
    12 Steps toworkload Tuning 1. Backup Production Database 2. Capture Production Workload 3. Analyze Workload and Script Changes (Don’t Implement) 4. Restore Backup on Test Server 5. Prepare to capture Workload on Test Server 6. Replay Production Workload on Test Server 14
  • 15.
    12 Steps toworkload Tuning 1. Backup Production Database 2. Capture Production Workload 3. Analyze Workload and Script Changes (Don’t Implement) 4. Restore Backup on Test Server 5. Prepare to capture Workload on Test Server 6. Replay Production Workload on Test Server 7. Analyze to Establish Baseline 15
  • 16.
    12 Steps toworkload Tuning 1. Backup Production Database 2. Capture Production Workload 3. Analyze Workload and Script Changes (Don’t Implement) 4. Restore Backup on Test Server 5. Prepare to capture Workload on Test Server 6. Replay Production Workload on Test Server 7. Analyze to Establish Baseline 8. Restore Backup on Test Server 16
  • 17.
    12 Steps toworkload Tuning 1. Backup Production Database 2. Capture Production Workload 3. Analyze Workload and Script Changes (Don’t Implement) 4. Restore Backup on Test Server 5. Prepare to capture Workload on Test Server 6. Replay Production Workload on Test Server 7. Analyze to Establish Baseline 8. Restore Backup on Test Server 9. Make Changes to Improve Performance on Test Server 17
  • 18.
    12 Steps toworkload Tuning 1. Backup Production Database 2. Capture Production Workload 3. Analyze Workload and Script Changes (Don’t Implement) 4. Restore Backup on Test Server 5. Prepare to capture Workload on Test Server 6. Replay Production Workload on Test Server 7. Analyze to Establish Baseline 8. Restore Backup on Test Server 9. Make Changes to Improve Performance on Test Server 10. Prepare to Capture Production Workload on Test Server 18
  • 19.
    12 Steps toworkload Tuning 1. Backup Production Database 2. Capture Production Workload 3. Analyze Workload and Script Changes (Don’t Implement) 4. Restore Backup on Test Server 5. Prepare to capture Workload on Test Server 6. Replay Production Workload on Test Server 7. Analyze to Establish Baseline 8. Restore Backup on Test Server 9. Make Changes to Improve Performance on Test Server 10. Prepare to Capture Production Workload on Test Server 11. Replay Workload on Test Server 19
  • 20.
    12 Steps toworkload Tuning 1. Backup Production Database 2. Capture Production Workload 3. Analyze Workload and Script Changes (Don’t Implement) 4. Restore Backup on Test Server 5. Prepare to capture Workload on Test Server 6. Replay Production Workload on Test Server 7. Analyze to Establish Baseline 8. Restore Backup on Test Server 9. Make Changes to Improve Performance on Test Server 10. Prepare to Capture Production Workload on Test Server 11. Replay Workload on Test Server 12. Analyze and Compare Workload with Baseline *** Repeat Steps 8 to 12 as needed *** 20
  • 21.
    Where can thingsGo wrong? 21
  • 22.
    Meet the Bottlenecks MEMORY DISK (SPINDLES) CPU NETWORK LOCKING, BLOCKING & DEADLOCKS Photos: http://www.flickr.com/photos/kaiban/5159888367/lightbox/ and http://www.flickr.com/photos/moodog/504456253 and http://www.flickr.com/photos/marksze/4231115464 and http://www.flickr.com/photos/vvvracer/5264339383 and http://www.flickr.com/photos/iphil_photos/4962369046 22
  • 23.
    3 Options ToResolve bottlenecks 23
  • 24.
    3 Options ToResolve bottlenecks 1. Reduce Workload 24
  • 25.
    3 Options ToResolve bottlenecks 1. Reduce Workload 2. Tune Workload to reduce bottleneck resource 25
  • 26.
    3 Options ToResolve bottlenecks 1. Reduce Workload 2. Tune Workload to reduce bottleneck resource 3. Add additional Hardware 26
  • 27.
    Viewing Wait Stats •Sys.dm_os_wait_stats • Wait stats can be cleared manually or during restart. – DBCC SQLPERF(‘sys.dm_os_wait_stats’, CLEAR) • Focus on waits dedicated to bottlenecks 27
  • 28.
    Common WAIT STATS • ASYNC_NETWORK_IO • LCK_M_* • IO_COMPLETION • PAGELATCH_* or PAGEIOLATCH_* • WRITELOG • CX_PACKET • SOS_SCHEDULER_YIELD 28
  • 29.
  • 30.
    Memory Performance counters You Want Description Object Counter > 256 MB Unused physical memory Memory Available Mbytes < 10 Reads from hard disk per second to memory Memory Pages Input/sec > 300 On average, how many seconds SQL Server expects page to say in cache (memory) SQL Server: Buffer Manager Page Life Expectancy Shows amount of memory SQL Server is currently using. SQL Server: Memory Manager Total Server Memory (KB) Amount of memory that SQL Server wants to use based on configured max Server Memory setting SQL Server: Memory Manager Target Server Memory (KB) 0 Total number of processess pers second waiting for workspace memory grants SQL Server: Memory Manager Memory Grants Pending > 640 Total number of pages avaiable across all free lists. A value under 640 SQL Server: Buffer Manager Free Pages < 20 Number of times per second that the lazywritter process moves dirty page from buffer to disk. SQL Server: Buffer Manager LazyWrites/Sec 30
  • 31.
    Disk Performance Counters • The sys.dm_io_virtual_file_stats DMV can be used to get disk latency for individual sql server files. Object Counter You Want Description Avg. Disk sec/Read is the average time, in seconds, of a read of data from the disk.This analysis determines if any of the physical disks are responding slowly. Physical Disk Avg Disk Sec/Read < 25ms Avg. Disk sec/Write is the average time, in seconds, of a write of data to the disk. Physical Disk Avg Disk Sec/Write < 25ms Disk Reads/sec is the rate of read operations on the disk. Physical Disk Disk Reads/sec Disk Writes/sec is the rate of write operations on the disk. Physical Disk Disk Writes/sec 31
  • 32.
    CPU Performance Counters Object Counter You Want Description < 80% Percentage of processor time spent on SQL Server process threads. Process (sqlservr) %Processor Time < 80% Percentage of elapsed time the processor spends executing non-idle threads. Processor %Processor Time 32
  • 33.
    General Workload performance counters Object Counter You Want Description Number of SQL batch requests received by server. This counter measures the number of batch requests that SQL Server receives per Batch Requests/Sec second, and generally follows in step to how busy your server's CPUs SQL Server: SQL Statistics (SQL2005/08) are. < 10% of the number of Number of SQL compilations. SQL Server: SQL Statistics SQL Compilations/sec batch request/sec < 10% of the number of Number of SQL re-compiles. This needs to be 0 as much as possible. A compilations/sec recompile can cause deadlocks and compile locks that are not SQL Server: SQL Statistics SQL Re-Compilations/sec compatible with any locking type. SQL Server: SQL Statistics User Connections 1 Full scan for every 1000 This counter monitors the number of full scans on base tables or index searches indexes. High values indicate that we may be having performance SQL Server: Access Methods Full Scans/sec issues due to table / index page scans. This counter measures the number of index searches per second. Index searches are used to start range scans, single index record fetches, and to reposition within an index. Index searches are preferable to index SQL Server: Access Methods Index Searches/sec and table scans. Number of page splits per second that occur as a result of overflowing index pages. Reduce non-sequential inserts or use fill factor and SQL Server: Access Methods Page Splits/sec pad_index to leave more empty space per page. 33
  • 34.
    Locking Performance Counters Object Counter You Want Description Number of lock requests per second SQL Server: Locks Number of Deadlocks/sec <1 that resulted in deadlock. Number of times SQL escalated locks to table level. This can indicate SQL Server: Locks Table Lock Escalations/sec poorly coded transactions. The average wait time for each lock SQL Server: Locks Avg Wait Time (ms) < 500 request that had to wait. Number of currently blocked SQL Server: General Statistics Processes blocked processes. 34
  • 35.
    DEMO!!! • Review Perfmon •Review PAL Tool – Collection Process – Generating Reports – Reviewing Reports 35
  • 36.
    Execution DMV’s • Sys.dm_exec_session – Returns one row per authenticated session, including user and system processes. • Sys.dm_exec_requests – Returns one row for each request executing within SQL Server, doesn’t include code executed outside of SQL (distributed queries, extended stored procedures etc…) • Sys.dm_exec_query_stats – Returns one row per query statement with cached plan, detailing aggregated performance stats for cached plans. • Sys.dm_exec_connections – Returns server information about a connection to SQL Server including client network address, TCP Port etc.. 36
  • 37.
    Query details DMV’S •Sys.dm_exec_sql_text – Returns the text of the SQL Server batch that is identified by specific sql handle. • Sys.dm_exec_text_query_plan – Returns the showplan output in text format. • Sys.dm_query_plan – Returns a given query’s showplan output in xml. 37
  • 38.
    INDEX DMV’s • Sys.dm_db_index_usage_stats – Returns a count of index operations including seeks, scans, lookup and updates • Sys.dm_db_index_physical_stats – Returns size and fragmentation information for data pages and indexes. • DMV’s to find recommended indexes – Sys.dm_db_missing_index_columns – Sys.dm_db_missing_index_details – Sys.dm_db_missing_index_groups – Sys.dm_db_missing_index_group_stats 38
  • 39.
    SQLOS DMV’s • Sys.dm_os_sys_memory – Returns complete picture of memory at the os level including total and available memory. • Sys.dm_os_tasks – Returns a row for each OS task thais is active in the instance of SQL Server. • Sys.dm_os_threads – Returns a row for each SQLOS thread running under the SQL Server process. • Sys.dm_os_performance_counters – Returns a row for each SQL Server perfmon counter. • Sys.dm_os_waiting_tasks – Returns information about the wait queue of SQLOS. This would be tasks waiting on resources like blocking and latch contention etc.. 39
  • 40.
    DMV Queries (DEMO) http://www.flickr.com/photos/democonference/4458079104 • What is Running? • Probing the Proc Cache 40
  • 41.
    SQL Profiler (DEMO!) http://www.flickr.com/photos/democonference/4458079104 • Generate Server Side traces – Tuning Columns and Events – Remove the noise • Read Trace with Clear Trace 41
  • 42.
    SQL Diag (DEMO) http://www.flickr.com/photos/democonference/4458079104 • Review SQL Diag • Review PerStats Scripts • Collect perfmon, sql trace, blocking and more… 42
  • 43.
    SQL NEXUS (DEMO) http://www.flickr.com/photos/democonference/4458079104 • Import SQLDiag • Analysis collected data 43
  • 44.
    RML Utilities (DEMO) http://www.flickr.com/photos/democonference/4458079104 • Ostress (Replay) • ReadTrace (Compare Workload to Baseline) 44
  • 45.
    Help I needSome One!!!! • Performance Virtual Chapter – http://performance.sqlpass.org/ • Twitter (#sqlhelp) • Message boards – www.sqlservercentral.com – www.msdn.com • Blogs • Consultants 45
  • 46.
    Where to gonext? • HTTP://JOHNSTERRETT.COM/GO/PERFORMANCE – Videos – Reference Links – Slides 46
  • 47.
    Thank You toour Sponsors