Download presentation
Presentation is loading. Please wait.
Published byThomas Wright Modified over 9 years ago
1
Enterprise Database Administration & Deployment SIG ▪ 313M ▪ Sept 29, 2005 ▪ 10:15 AM SQL Server 2005 Performance Diagnosis and Tuning using SQL Tools and DMVs Shawn Nesser (Borrowed from Vipul Shah)
2
Enterprise Database Administration & Deployment SIG ▪ 313M ▪ Sept 29, 2005 ▪ 10:15 AM Session Objectives And Key Takeaways Session Objectives: How Tools and DMVs can be used to monitor and tune SQL Server 2005 Walk away with demo scripts you can use Key Takeaways: Maximize benefit from Tools and DMVs for monitoring and tuning SQL Server 2005
3
Enterprise Database Administration & Deployment SIG ▪ 313M ▪ Sept 29, 2005 ▪ 10:15 AM Agenda New Capabilities in SQL Server 2005 Management Studio Reports Identify Top SQL (delta) I/O Tuning Contention Tuning SQL Server Profiler Demo Code is at end of slides (see Notes)
4
Enterprise Database Administration & Deployment SIG ▪ 313M ▪ Sept 29, 2005 ▪ 10:15 AM New Capabilities in SQL 2005? Dynamic Management Views (DMVs) Views on memory structures in the Engine Monitor activity inside the Engine Trace Events New trace events that complete the picture provided by DMVs Light-weight, ON-by-default trace to capture schema and configuration changes Dedicated Administration Connection
5
Enterprise Database Administration & Deployment SIG ▪ 313M ▪ Sept 29, 2005 ▪ 10:15 AM New Capabilities in SQL 2005? (continued) Database Engine Tuning Advisor Gives Partitions recommendations Indexes and Indexed Views recommendations Statistics recommendations Tunes multiple databases Time-bound and Storage-bound tuning XML ShowPlan MissingIndexes tag Indexes that query optimizer would use if available
6
Enterprise Database Administration & Deployment SIG ▪ 313M ▪ Sept 29, 2005 ▪ 10:15 AM New Capabilities in SQL 2005? (continued) Management Studio contains performance reports Reports are available at server level Reports are available at database level SQL Server Profiler allows for correlation with Performance Counters Enhances ability to isolate problems
7
Enterprise Database Administration & Deployment SIG ▪ 313M ▪ Sept 29, 2005 ▪ 10:15 AM Database Management Views Views built on top of internal structures Ideal for tracking performance Server Level Component Level dm_exec_* Execution of user code and associated connections dm_os_* Memory, locking & scheduling dm_tran_* Transactions & isolation dm_io_* I/O on network and disks dm_db_* Databases and database objects dm_repl_*Replicationdm_broker_* SQL Service Broker dm_fts_* Full Text Search dm_qn_* Query Notifications dm_clr_* Common Language Runtime
8
Enterprise Database Administration & Deployment SIG ▪ 313M ▪ Sept 29, 2005 ▪ 10:15 AM Default Trace Light-weight tracing is ON by default Captures schema changes and configuration changes Trace is captured in rolling window of 5 trace files 20MB each (maximum of 100MB) Old trace files are deleted 100MB limit is never exceeded New trace file is created after every re-start No more than 5 trace files are available
9
Enterprise Database Administration & Deployment SIG ▪ 313M ▪ Sept 29, 2005 ▪ 10:15 AM Management Studio Reports Reports get data from DMVs and Default Trace files Use these Reports for an overview Server-level Reports Select SQL Server instance node in Object Explorer, select View Summary menu, and Report drop-list Database-level Reports Select a database node in Object Explorer, select View Summary menu, and Report drop-list
10
Enterprise Database Administration & Deployment SIG ▪ 313M ▪ Sept 29, 2005 ▪ 10:15 AM
11
Management Studio Reports Vipul Shah Program Manager SQL Server
12
Enterprise Database Administration & Deployment SIG ▪ 313M ▪ Sept 29, 2005 ▪ 10:15 AM Tracking Server Activity Track activity by Wait types Waits indicate where server spends its activity Focus on wait event with highest wait time Track SQL statements How do you track Top SQL and Waits? “Performance – Top Queries” report in Management Studio shows you top queries since instance start time Use DMVs to track activity in an interval QueryStatsDelta script is an example
13
Enterprise Database Administration & Deployment SIG ▪ 313M ▪ Sept 29, 2005 ▪ 10:15 AM Tracking Server Activity (continued) “QueryStatsDelta” script Uses dm_exec_query_stats Takes before and after snapshots and diffs them Accounts for new statements in the interval Orders top SQL by elapsed time Shows exact SQL statement by extracting it from batch text Uses dm_os_wait_stats Takes before and after snapshots and diffs them Removes Idle waits and Trace waits Orders top wait events by wait duration
14
Enterprise Database Administration & Deployment SIG ▪ 313M ▪ Sept 29, 2005 ▪ 10:15 AM
15
Identify Top SQL Vipul Shah Program Manager SQL Server
16
Enterprise Database Administration & Deployment SIG ▪ 313M ▪ Sept 29, 2005 ▪ 10:15 AM Tuning I/O Intensive SQL Use “MissingIndexes” tag in XML Show Plan for single statement-focused analysis Very useful when workload is not available or workload is incomplete Missing indexes is NOT a recommendation Optimizer would have used these indexes if available Remember – creating these indexes may slow Inserts, Updates and Deletes Track index usage if you choose to create a missing index Weight the costs-benefits of the index
17
Enterprise Database Administration & Deployment SIG ▪ 313M ▪ Sept 29, 2005 ▪ 10:15 AM Tuning I/O Intensive SQL (continued) Use Database Engine Tuning Advisor for comprehensive workload analysis Feed workload input to DTA Collect workload using “Tuning” template in SQL Server Profiler, or Collect workload as SQL script Select the database for workload analysis Select the databases to tune Set a time-bound Review output from analysis Review reports to make educated choice
18
I/O Tuning Vipul Shah Program Manager SQL Server
19
Enterprise Database Administration & Deployment SIG ▪ 313M ▪ Sept 29, 2005 ▪ 10:15 AM How do I track index usage? Use dm_db_missing_index_group_stats, dm_db_missing_index_groups, dm_db_missing_indexes Identify frequently used and less frequently used indexes Do not drop index without careful consideration !
20
Enterprise Database Administration & Deployment SIG ▪ 313M ▪ Sept 29, 2005 ▪ 10:15 AM Detecting Contention “Activity – All Blocking Transactions” report in Management Studio is excellent for seeing blocked transactions at that moment “Blocked Process Report” trace event To set 5 second blocked process report sp_configure 'blocked process threshold', 5 “Deadlock Graph” trace event DMV dm_os_wait_stats shows aggregate duration spent on lock waits
21
Enterprise Database Administration & Deployment SIG ▪ 313M ▪ Sept 29, 2005 ▪ 10:15 AM Tuning Contention SQL Server 2000 – tradeoff between consistency and concurrency SQL Server 2005 - use Row-Versioning based isolation levels Eliminates locking Uses version store to keep old row versions No tradeoff between consistency and concurrency Read Committed Snapshot isolation level Provides statement level consistency Snapshot isolation level Provides transaction level consistency
22
Enterprise Database Administration & Deployment SIG ▪ 313M ▪ Sept 29, 2005 ▪ 10:15 AM Tuning Contention (continued) Use Read Committed Snapshot isolation level Most existing applications require no change OFF by default Turn it ON per database Works with distributed transactions
23
Detecting Contention and Deadlocks Vipul Shah Program Manager SQL Server
24
Enterprise Database Administration & Deployment SIG ▪ 313M ▪ Sept 29, 2005 ▪ 10:15 AM Performance Correlation in Profiler SQL Server Profiler Use to Trace events Use to Replay events Correlate Performance Counters to isolate problems quickly
25
Performance Counter Correlation in Profiler Vipul Shah Program Manager SQL Server
26
Enterprise Database Administration & Deployment SIG ▪ 313M ▪ Sept 29, 2005 ▪ 10:15 AM Thank you! Thank you for attending this session and the 2005 PASS Community Summit in Grapevine! Please help us improve the quality of our conference by completing your session evaluation form. Completed evaluation forms may be given to the room monitor as you exit or to staff at the registration desk.
27
Create Tables Requires AdventureWorks database Requires AdventureWorks database Script is in Notes section Script is in Notes section Scripts
28
Create Scheduled Job Scripts Requires AdventureWorks database Requires AdventureWorks database Script is in Notes section Script is in Notes section
29
Create Stored Procedures Scripts Requires AdventureWorks database Requires AdventureWorks database Creates SPs and Functions for TopSQL and TopWaits Creates SPs and Functions for TopSQL and TopWaits Script is in Notes section Script is in Notes section
30
Workload Without DML Scripts Requires AdventureWorks database Requires AdventureWorks database Script is in Notes section Script is in Notes section
31
Workload With DML Scripts Requires AdventureWorks database Requires AdventureWorks database Script is in Notes section Script is in Notes section
32
Demo Queries Scripts Requires AdventureWorks database Requires AdventureWorks database Script is in Notes section Script is in Notes section
33
ReaderReader Scripts Requires Snapshots database Requires Snapshots database Script is in Notes section Script is in Notes section
34
WriterWriter Scripts Requires Snapshots database Requires Snapshots database Script is in Notes section Script is in Notes section
35
First Part of Deadlock Scripts Requires AdventureWorks database Requires AdventureWorks database Script is in Notes section Script is in Notes section
36
Second Part of Deadlock Scripts Requires AdventureWorks database Requires AdventureWorks database Script is in Notes section Script is in Notes section
37
Enterprise Database Administration & Deployment SIG ▪ 313M ▪ Sept 29, 2005 ▪ 10:15 AM © 2005 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.
Similar presentations
© 2024 SlidePlayer.com Inc.
All rights reserved.