Introduction. Part I: Finding Bottlenecks when Something s Wrong. Chapter 1: Performance Tuning 3



Similar documents
SQL Server Performance Tuning and Optimization

Microsoft SQL Server: MS Performance Tuning and Optimization Digital

Server 2008 SQL. Administration in Action ROD COLLEDGE MANNING. Greenwich. (74 w. long.)

W I S E. SQL Server 2008/2008 R2 Advanced DBA Performance & WISE LTD.

Mind Q Systems Private Limited

SQL Server 2012 Optimization, Performance Tuning and Troubleshooting

SQL Server 2012 Database Administration With AlwaysOn & Clustering Techniques

Microsoft SQL Database Administrator Certification

Oracle Database 11 g Performance Tuning. Recipes. Sam R. Alapati Darl Kuhn Bill Padfield. Apress*

SQL Server 2008 Administration

SQL Server 2008 Designing, Optimizing, and Maintaining a Database Session 1

Beginning SQL Server Administration. Apress. Rob Walters Grant Fritchey

MS SQL Server 2014 New Features and Database Administration

Performance Tuning and Optimizing SQL Databases 2016

MS SQL Performance (Tuning) Best Practices:

Microsoft SQL Server 2012 Administration

AV-005: Administering and Implementing a Data Warehouse with SQL Server 2014

6231B: Maintaining a Microsoft SQL Server 2008 R2 Database

Administering Microsoft SQL Server 2012 Databases

Before attending this course, participants should have:

NUTECH COMPUTER TRAINING INSTITUTE 1682 E. GUDE DRIVE #102, ROCKVILLE, MD WEB: TEL:

Would-be system and database administrators. PREREQUISITES: At least 6 months experience with a Windows operating system.

Expert Oracle Exadata

SQL Server 2012 Query. Performance Tuning. Grant Fritchey. Apress*

10775 Administering Microsoft SQL Server Databases

"Charting the Course... MOC AC SQL Server 2014 Performance Tuning and Optimization. Course Summary

W I S E. SQL Server 2012 Database Engine Technical Update WISE LTD.

FHE DEFINITIVE GUIDE. ^phihri^^lv JEFFREY GARBUS. Joe Celko. Alvin Chang. PLAMEN ratchev JONES & BARTLETT LEARN IN G. y ti rvrrtuttnrr i t i r

MOC 20462C: Administering Microsoft SQL Server Databases

MCTS Microsoft SQL Server 2005 Implementation & Maintenance

Below are the some of the new features of SQL Server that has been discussed in this course

ExecuTrain Course Outline MOC 6231B: Maintaining a Microsoft SQL Server 2008 R2 Database

System Administration of Windchill 10.2

Course 20462C: Administering Microsoft SQL Server Databases

Oracle Database 12c: Performance Management and Tuning NEW

Microsoft SQL Server Beginner course content (3-day)

10775A Administering Microsoft SQL Server 2012 Databases

Administering Microsoft SQL Server Databases

SQL Server. DMVs in Action. Better Queries with. Dynamic Management Views MANNING IANW. STIRK. Shelter Island

The Complete Performance Solution for Microsoft SQL Server

Oracle Database 11g: SQL Tuning Workshop Release 2

6231B: Maintaining a Microsoft SQL Server 2008 R2 Database

Maintaining a Microsoft SQL Server 2008 Database

Microsoft SQL Server performance tuning for Microsoft Dynamics NAV

Course 55144: SQL Server 2014 Performance Tuning and Optimization

Course 6231B: Maintaining a Microsoft SQL Server 2008 R2 Database

PERFORMANCE TUNING IN MICROSOFT SQL SERVER DBMS

Explain how to prepare the hardware and other resources necessary to install SQL Server. Install SQL Server. Manage and configure SQL Server.

Microsoft SQL Server 2008 Administrator's Pocket Consultant

ONSITE TRAINING CATALOG

MOC Administering Microsoft SQL Server 2014 Databases

How To Improve Performance In A Database

Oracle Database 11g: Performance Tuning DBA Release 2

Design and Implementation

Online Transaction Processing in SQL Server 2008

Oracle Database 11g: SQL Tuning Workshop

The Database is Slow

Administering Microsoft SQL Server 2012 Databases

50238: Introduction to SQL Server 2008 Administration

LearnFromGuru Polish your knowledge

Administering Microsoft SQL Server Databases

Optimizing Performance. Training Division New Delhi

Professional SQL Server 2012 Internals and Troubleshooting

Course Syllabus. At Course Completion

Administering Microsoft SQL Server Databases

SQL Server 2014

MS-10775: Administering Microsoft SQL Server 2012 Databases. Course Objectives. Required Exam(s) Price. Duration. Methods of Delivery.

Administering Microsoft SQL Server Databases

Course Syllabus. Maintaining a Microsoft SQL Server 2005 Database. At Course Completion

6231A - Maintaining a Microsoft SQL Server 2008 Database

MS Administering Microsoft SQL Server Databases

Administering Microsoft SQL Server Databases

David Dye. Extract, Transform, Load

SQL Server 2012 Performance White Paper

$99.95 per user. SQL Server 2005 Database Administration CourseId: 152 Skill level: Run Time: 30+ hours (158 videos)

Microsoft Official Courseware

20464C: Developing Microsoft SQL Server Databases

Course. Overview. Length: 5 Day(s) Published: English. IT Professionals. Level: Type: Method: Delivery. Enroll now (CAL)

This presentation is an introduction to the SQL Server Profiler tool.

SQL Sentry Essentials

VirtualCenter Database Performance for Microsoft SQL Server 2005 VirtualCenter 2.5

ADMINISTERING MICROSOFT SQL SERVER DATABASES

MOC 20461C: Querying Microsoft SQL Server. Course Overview

Implementing a Microsoft SQL Server 2005 Database

20462C: Administering Microsoft SQL Server Databases

MODULE FRAMEWORK : Dip: Information Technology Network Integration Specialist (ITNIS) (Articulate to Edexcel: Adv. Dip Network Information Specialist)

DMS Performance Tuning Guide for SQL Server

Developing Microsoft SQL Server Databases 20464C; 5 Days

Administering Microsoft SQL Server Databases

Designing, Optimizing and Maintaining a Database Administrative Solution for Microsoft SQL Server 2008

SQL Server Training Course Content

Administering Microsoft SQL Server Databases 20462C; 5 days

Administering Microsoft SQL Server Databases

Administering Microsoft SQL Server Databases

1. This lesson introduces the Performance Tuning course objectives and agenda

Transcription:

Wort ftoc.tex V3-12/17/2007 2:00pm Page ix Introduction xix Part I: Finding Bottlenecks when Something s Wrong Chapter 1: Performance Tuning 3 Art or Science? 3 The Science of Performance Tuning 4 The Problem Statement 4 ThePlanofAttack 6 Data Collection 6 Data Analysis 7 Performance Tuning Applied 7 Example 1 Your Application Is Slow 7 Example 2 Stored Procedure X Is Slow 9 Tools 10 Preventative Measures 13 Summary 14 Chapter 2: Monitoring Server Resources with System Monitor 15 Why Might I Need System Monitor? 15 When Should I Use System Monitor? 16 Performance Monitor Overview 16 Getting Started with System Monitor 18 Performance Logs and Alerts 22 What s the Impact of Running System Monitor? 22 Managing Monitoring Impact 23 Capturing at the Right Time, for the Right Duration 23 How Much Data Will System Monitor Generate? 23 Resource Utilization 24 Kernel Mode versus Application Mode 25 Identifying Bottlenecks 25 Locating Memory Bottlenecks 25 Discovering Disk Bottlenecks 27 Identifying CPU Bottlenecks 28 COPYRIGHTED MATERIAL

Wort ftoc.tex V3-12/17/2007 2:00pm Page x Using System Monitor Proactively 29 Running System Monitor on 64-bit Systems 29 Combining System Monitor Logs and SQL Profiler Traces 30 Monitoring Remote Servers 31 Best Practices for System Monitor 31 Taking a Baseline 31 Retaining Performance Logs 32 Patterns and Trends 32 Servers Suffering Very Poor Performance 32 Tuning Performance 32 Being Proactive 32 My System Monitor Counters Are Missing What Should I Do? 33 Built-in Log Management Tools 34 LogMan 35 Relog 35 Analyzing Log Data 35 LogParser 36 Performance Analysis of Logs 36 Summary 38 Chapter 3: Monitoring SQL Server Resources with System Monitor 39 The Beginning 40 Types of Performance Problems 40 Configuration-Based Performance Problems 41 Schema-Based Performance Problems 41 Types of Bottlenecks 42 Memory Bottlenecks 43 Types of Memory Bottlenecks 43 Confirming Memory Bottlenecks 44 Configuration-Based Memory Bottlenecks 45 Schema-Based Memory Bottlenecks 46 CPU Bottlenecks 46 Confirming CPU Bottlenecks 47 Configuration-Based CPU Bottlenecks 48 Schema-Based CPU Bottlenecks 48 Disk Bottlenecks 49 Confirming Disk Bottlenecks 50 Configuration-Based Disk Bottlenecks 50 Schema-Based Disk Bottlenecks 53 Monitoring Database Mirroring Performance 54 x

Wort ftoc.tex V3-12/17/2007 2:00pm Page xi Monitoring Wait Statistics 55 Typical Performance Problems 55 Typical Disk Problems 56 Memory 56 Typical CPU Problems 57 Using SQL Server to Analyze Performance Logs 59 Combining Performance Monitor Logs and SQL Profiler Trace 64 Summary 65 Chapter 4: SQL Server Wait Types 67 SQL Server Waits 68 Architecture 68 Common or Noteworthy Resource Wait Types 69 How to Track Waits 70 sys.dm exec requests Session Level Information Only 70 sys.dm os waiting tasks All Waiting Tasks 71 sys.dm os wait stats Aggregated Times by Wait Type 71 DMVStats 72 Performance Dashboard 73 Wait Stats in Action 73 Locking and Blocking 79 Concurrency 79 Transactions 81 Isolation Levels 81 Locks and Locking 82 Row Versioning 85 Monitoring for Deadlocks 86 Monitoring for Blocking Locks 89 Summary 91 Chapter 5: Finding Problem Queries with SQL Profiler 93 Preparations for Setting Up a Trace 93 Checking for a Complete Issue Statement 94 Searching for Related Known Issues 94 Thinking in Terms of SQL Trace Terminologies 94 SQL Trace Options and Considerations 99 Capturing Blocking Events 104 Capturing Showplan XML Data 107 Capturing Deadlock Graphs 110 xi

Wort ftoc.tex V3-12/17/2007 2:00pm Page xii Identifying Long-Running Queries Using SQL Profiler 114 Simulating a Scenario and a Sample Database 115 Analyzing the Issue 115 Setup 115 Tracing 118 Analysis and Tuning 119 Case Summary 122 Tracing Costly Queries by Using Profiler to Generate Server-Side Trace Code 122 Using Profiler to Generate Server-Side Trace Script 123 Executing Server-Side Scripts 126 Handling Trace Files and Analyzing Trace Data 126 Server-Side Trace Code Walk-Through 131 Case Summary 137 Correlating a Profiler Trace with System Monitor Performance Counter Data 137 Summary 139 Part II: Removing Bottlenecks with Tuning Chapter 6: Choosing and Configuring Hardware 143 Server Bottlenecks 143 Memory 144 I/O 144 CPU 144 Configuring the Server 145 Memory 147 I/O 153 CPU 162 Summary 170 Chapter 7: Tuning SQL Server Configuration 171 Considerations before Adjusting Server Level Settings 171 Inspecting Current SQL Server Settings 172 Inspecting Server Settings with SQL Server Management Studio 172 Inspecting Server Settings with Scripts 173 Important Server Settings: CPU, Memory, and I/O 175 Memory 182 Network I/O 182 Summary 187 xii

Wort ftoc.tex V3-12/17/2007 2:00pm Page xiii Chapter 8: Tuning the Schema 189 Data Quality 189 Normalization 189 Denormalization 196 Defining Columns 197 Stored Procedures 214 Triggers 218 Data Performance 221 Pages 221 Partitioning 224 Concurrency and Locking (and Blocking) 227 Locks 229 Indexing 232 Summary 237 Chapter 9: Tuning T-SQL 239 Opening Move: The Optimizer s Gameplan 239 Cost-Based Optimization 240 Reading Index Statistics 241 Include Actual Execution Plan Misconception 242 Use sp helpindex to Examine Indexes 242 Middle Game: Gathering the Facts 243 Query Plans 243 Query Plan Essentials 244 Buffer Pool 263 End Game: Performance Tuning T-SQL 268 Essential Tools 269 Prerequisite Indexes for Examples 270 Tuning T-SQL with a New Approach 270 NOT IN and NOT EXISTS Rewrites are in the Past 270 Rewriting by Pushing Predicates Deeper into Plans 271 Using Temp Tables for Intermediary Results 273 User-Defined Functions in SELECT Statements 274 Reworking SELECT 276 Tuning the T-SQL Predicate 280 Removing Certain Implicit Conversions 280 Using Searchable Arguments 282 Tuning T-SQL to Use Indexes 285 Minimizing Bookmark Lookups 285 Ordering Results 288 xiii

Wort ftoc.tex V3-12/17/2007 2:00pm Page xiv Handling Indexed Nullable Columns 288 Eliminating Duplicates 290 Tuning T-SQL Common Patterns or Idioms 292 Singleton SELECT Statements 292 Aggregates and CTEs 295 Derived Tables and Correlated Subqueries 298 Paging and Sorting 302 Tuning the T-SQL Statement with Hints 309 Query Plan Caching Issues 309 Tuning for Deadlocking and Blocking 312 Blocking 312 Deadlocks 312 Preventative Measures 313 Simulated Stress Testing for Query Plans 316 Summary 318 Part III: Preventative Measures and Baselining Performance with Tools Chapter 10: Capturing, Measuring, and Replaying a Workload Using SQL Profiler 321 Capturing Workloads for Replay 321 Characterizing a Workload for Replay 322 Meeting Requirements for Workload Replays 324 Capturing a Workload 326 Modifying a Workload in a Trace Table for Special Needs 327 Measuring Workload Performance 330 Preliminary Analysis of the Workload 330 New Performance Reference for a Workload Replay 334 Replaying a Workload 337 Workload Generation for Case Scenarios 338 Scenario 1: Validating Performance Improvement 340 Scenario 2: Replaying a Workload in Different Environments and Measuring Overall Response Time 343 Scenario 3: Replaying Multiple Workloads on a Target Server 346 Summary 352 Chapter 11: Tuning Indexes 353 Sample Database 353 Section 1: Indexing Review 355 B-Trees 355 xiv

Wort ftoc.tex V3-12/17/2007 2:00pm Page xv The Fill Factor 356 Clustered Indexes 357 Heaps 359 Nonclustered Indexes 359 Statistics 360 Indexed Views 364 Section 2: Tuning with DTA 365 Using DTA to Tune Individual Queries 366 Indexes for Updates 374 Reassessing Inserts after Adding Update Indexes 386 Too Many Indexes? 389 Tuning a Workload 392 Section 3: Index Maintenance 393 Monitoring Index Fragmentation 394 Removing Fragmentation 395 Section 4: Partitioned Tables and Indexes 397 Reasons for Using Partitioned Tables and Indexes 397 Prerequisites for Partitioning 398 Creating Partitioned Tables 398 Summary 407 Chapter 12: How Fast and Robust Is Your Storage? 409 Performance Testing, Stress Testing, and Real-Life Performance 409 Performance Testing 410 Stress Testing 410 Real-Life Performance 410 Putting It All Together 411 Storage Performance 412 Storage Performance Measuring Tools 412 What Do You Want to Measure? 413 Measuring I/O Performance 414 Using SQLIO 423 Storage Reliability 454 SQLIOSim 454 Using SQLIOSim 455 Best Practice for SQLIOSim Test Duration 458 Running Other Tests 459 Running SQLIOSim from the Command Line 467 Interpreting Results from SQLIOSim 467 Summary 470 xv

Wort ftoc.tex V3-12/17/2007 2:00pm Page xvi Chapter 13: SQL Server 2005 Performance Dashboard Reports 471 Supportability 472 Catalog Views 472 Dynamic Management Views and Functions 472 The Default Trace 473 Difficulties 477 Performance Dashboard Reports 477 Prerequisites 477 Installing the Performance Dashboard Reports 478 Running the Performance Dashboard Reports 481 Architecture 485 Common Usage Scenarios 488 Limitations 492 Related Links 494 Summary 494 Part IV: Roadmap to Server Performance Chapter 14: Best Practices for Designing for Performance from the Start 497 Understanding Your Performance Requirements 498 How Many Users Will the Database Support? 498 What Is the Nature of the User-Role Access Requirements? 500 What Is the Required Throughput of Business Transactions? 501 What Is the Software Application s Core Architecture? 504 Evaluating Schemas for Performance Unknowns 505 Simple Schemas 506 Single-Use Tables 506 Single-Use Columns 507 Eliminating Ambiguous Null Fields 509 ID-Based Partitioning 510 Denormalization for Performance 510 Performance Effect of Functions in Views 512 Evaluating Indexes for Performance 513 No-Thought/Default Indexing 513 Simple Access Pattern Indexing 514 Complex Access Pattern Indexing 514 Benchmarking for Evaluation 514 Creating the Benchmark Schema 514 Extracting Object_Id-Level Information from DMVs 515 xvi

Wort ftoc.tex V3-12/17/2007 2:00pm Page xvii Capturing Table Throughput 515 Monitoring Index Usage 516 TempDB Usage 516 Capturing Blocking Information 517 Monitoring High CPU Usage 518 Monitoring High I/O Offenders 519 Communicating Performance Issues 519 Summary 521 Chapter 15: Successful Deployment Strategies 523 Sizing 524 Additional Features 525 High Availability and Disaster Recovery 526 Backup and Restore 526 Clustering 527 Database Mirroring 527 Log Shipping 528 Replication 528 Load Testing 528 Managing Change 529 Dealing with Large Tables 530 Partition Functions 530 Partition Schemes 531 Partition Tables or Indexes 531 Tuning Using SQL Server Profiler 532 Tuning Using the Database Engine Tuning Advisor 532 Consequences of Incorrectly Sizing the Production Environment 532 Schema Issues in Production 533 Avoiding Changing Code to Fix Issues 534 The Query 534 The Query Plan 535 ThePlanGuide 536 The Query Plan after Creation of the Plan Guide 536 Summary 537 Index 539 xvii

Wort ftoc.tex V3-12/17/2007 2:00pm Page xviii