Performance Tuning for Pirates!
Upcoming SlideShare
Loading in...5
×
 

Performance Tuning for Pirates!

on

  • 4,987 views

This is the slide deck for my #24hop session on Performance Tuning for Pirates.

This is the slide deck for my #24hop session on Performance Tuning for Pirates.

Statistics

Views

Total Views
4,987
Views on SlideShare
2,373
Embed Views
2,614

Actions

Likes
1
Downloads
120
Comments
0

4 Embeds 2,614

http://johnsterrett.com 2604
http://www.twylah.com 5
http://www.linkedin.com 4
http://webcache.googleusercontent.com 1

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

Performance Tuning for Pirates! Performance Tuning for Pirates! Presentation Transcript

  • PERFORMANCE TUNING FORPIRATES!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 TeamMid-Atlantic Region MentorFounder of WVPASS (SQL UG)Host of SQL Saturday #36 and #80I reside in Wheeling, WV (Pittsburgh, PA) 2
  • Pirates and YankeesPhotos: 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 Tuning1. Backup Production Database 9
  • 12 Steps to workload Tuning1. Backup Production Database2. Capture Production Workload 10
  • 12 Steps to workload Tuning1. Backup Production Database2. Capture Production Workload3. Analyze Workload and Script Changes (Don’t Implement) *** Done with Production *** 11
  • 12 Steps to workload Tuning1. Backup Production Database2. Capture Production Workload3. Analyze Workload and Script Changes (Don’t Implement)4. Restore Backup on Test Server 12
  • 12 Steps to workload Tuning1. Backup Production Database2. Capture Production Workload3. Analyze Workload and Script Changes (Don’t Implement)4. Restore Backup on Test Server5. Prepare to capture Workload on Test Server 13
  • 12 Steps to workload Tuning1. Backup Production Database2. Capture Production Workload3. Analyze Workload and Script Changes (Don’t Implement)4. Restore Backup on Test Server5. Prepare to capture Workload on Test Server6. Replay Production Workload on Test Server 14
  • 12 Steps to workload Tuning1. Backup Production Database2. Capture Production Workload3. Analyze Workload and Script Changes (Don’t Implement)4. Restore Backup on Test Server5. Prepare to capture Workload on Test Server6. Replay Production Workload on Test Server7. Analyze to Establish Baseline 15
  • 12 Steps to workload Tuning1. Backup Production Database2. Capture Production Workload3. Analyze Workload and Script Changes (Don’t Implement)4. Restore Backup on Test Server5. Prepare to capture Workload on Test Server6. Replay Production Workload on Test Server7. Analyze to Establish Baseline8. Restore Backup on Test Server 16
  • 12 Steps to workload Tuning1. Backup Production Database2. Capture Production Workload3. Analyze Workload and Script Changes (Don’t Implement)4. Restore Backup on Test Server5. Prepare to capture Workload on Test Server6. Replay Production Workload on Test Server7. Analyze to Establish Baseline8. Restore Backup on Test Server9. Make Changes to Improve Performance on Test Server 17
  • 12 Steps to workload Tuning1. Backup Production Database2. Capture Production Workload3. Analyze Workload and Script Changes (Don’t Implement)4. Restore Backup on Test Server5. Prepare to capture Workload on Test Server6. Replay Production Workload on Test Server7. Analyze to Establish Baseline8. Restore Backup on Test Server9. Make Changes to Improve Performance on Test Server10. Prepare to Capture Production Workload on Test Server 18
  • 12 Steps to workload Tuning1. Backup Production Database2. Capture Production Workload3. Analyze Workload and Script Changes (Don’t Implement)4. Restore Backup on Test Server5. Prepare to capture Workload on Test Server6. Replay Production Workload on Test Server7. Analyze to Establish Baseline8. Restore Backup on Test Server9. Make Changes to Improve Performance on Test Server10. Prepare to Capture Production Workload on Test Server11. Replay Workload on Test Server 19
  • 12 Steps to workload Tuning1. Backup Production Database2. Capture Production Workload3. Analyze Workload and Script Changes (Don’t Implement)4. Restore Backup on Test Server5. Prepare to capture Workload on Test Server6. Replay Production Workload on Test Server7. Analyze to Establish Baseline8. Restore Backup on Test Server9. Make Changes to Improve Performance on Test Server10. Prepare to Capture Production Workload on Test Server11. Replay Workload on Test Server12. 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 & DEADLOCKSPhotos: http://www.flickr.com/photos/kaiban/5159888367/lightbox/ and http://www.flickr.com/photos/moodog/504456253 andhttp://www.flickr.com/photos/marksze/4231115464 and http://www.flickr.com/photos/vvvracer/5264339383 andhttp://www.flickr.com/photos/iphil_photos/4962369046 22
  • 3 Options To Resolve bottlenecks 23
  • 3 Options To Resolve bottlenecks1. Reduce Workload 24
  • 3 Options To Resolve bottlenecks1. Reduce Workload2. Tune Workload to reduce bottleneck resource 25
  • 3 Options To Resolve bottlenecks1. Reduce Workload2. Tune Workload to reduce bottleneck resource3. 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 DescriptionObject Counter > 256 MB Unused physical memoryMemory Available Mbytes < 10 Reads from hard disk per second to memoryMemory 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 settingSQL Server: Memory Manager Target Server Memory (KB) 0 Total number of processess pers second waiting for workspace memory grantsSQL Server: Memory Manager Memory Grants Pending > 640 Total number of pages avaiable across all free lists. A value under 640SQL 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 CountersObject 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 countersObject 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 servers CPUsSQL 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 notSQL 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 performanceSQL 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 indexSQL 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 andSQL Server: Access Methods Page Splits/sec pad_index to leave more empty space per page. 33
  • Locking Performance CountersObject Counter You Want Description Number of lock requests per secondSQL Server: Locks Number of Deadlocks/sec <1 that resulted in deadlock. Number of times SQL escalated locks to table level. This can indicateSQL Server: Locks Table Lock Escalations/sec poorly coded transactions. The average wait time for each lockSQL Server: Locks Avg Wait Time (ms) < 500 request that had to wait. Number of currently blockedSQL 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