Thông tin tài liệu
Professional
SQL Server
®
2005 Performance Tuning
Enhance Your Knowledge
Advance Your Career
Professional SQL Server 2005
Performance Tuning
978-0-470-17639-9
This book is for consultants, developers, DBAs, architects, or
anyone with an interest in SQL performance. A working knowledge of
T-SQL and knowledge of how to perform basic SQL Server and OS
administrative tasks is necessary.
Professional SQL Server 2005
Reporting Services
978-0-7645-8497-8
This book is for report designers, developers, administrators, and
business professionals interested in learning the advanced func-
tionality, report, server administration, and security issues of SQL
Server 2005 Reporting Services.
Professional SQL Server 2005 CLR Programming:
with Stored Procedures, Functions, Triggers,
Aggregates, and Types
978-0-470-05403-1
This book is for developers and architects who are familiar with
.NET concepts as well as DBAs who, although developers in
their own right, may be slightly less up to date on .NET. A solid
grounding in T-SQL is necessary.
Professional SQL Server 2005
Integration Services
978-0-7645-8435-0
This book offers best practices in design and development,
architectural approaches for reusability, and connectivity to
various other popular systems using Integration Services.
Professional SQL Server 2005 Programming
978-0-7645-8434-3
This book shows experienced developers how to master the
substantially revamped feature set for SQL Server 2005. Covers
such advanced topics as methods for handling stored procedures,
scripting and error handling, XML and XQuery support, security
and performance tuning, and sophisticated database design.
Beginning SQL Server 2005 Programming
978-0-7645-8433-6
A comprehensive introduction to SQL Server 2005. Addresses
creating and changing tables, managing keys, database normaliza-
tion, writing scripts, working with stored procedures, programming
with XML, and using SQL Server reporting and data transformation
services.
Get more Wrox
Programmer to Programmer
TM
at Wrox.com!
Special Deals
Take advantage of special offers
every month
Free Chapter Excerpts
Be the fi rst to preview chapters from
the latest Wrox publications
Unlimited Access. . .
. . . to over 200 of our books in the
Wrox Reference Library. (see more
details online)
Forums, Forums, Forums
Take an active role in online
discussions with fellow programmers
Meet Wrox Authors!
Read running commentaries from authors on their programming experiences
and whatever else they want to talk about
Join the community!
Sign up for our free monthly newsletter at
newsletter.wrox.com
BROWSE BOOKS P2P FORUM FREE NEWSLETTER ABOUT WROX
Browse Books
.NET
SQL Server
Java
XML
Visual Basic
C#/C++
spine=1.152"
www.it-ebooks.info
Wort ffirs.tex V3 - 12/19/2007 3:48pm Page i
Professional
SQL Server
®
2005
Performance Tuning
Acknowledgments viii
Introduction xix
Part I: Finding Bottlenecks when Something’s Wrong 1
Chapter 1: Performance Tuning . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
Chapter 2: Monitoring Server Resources with System Monitor . . . . . . . . . . . . . . 15
Chapter 3: Monitoring SQL Server Resources with System Monitor . . . . . . . . . 39
Chapter 4: SQL Server Wait Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67
Chapter 5: Finding Problem Queries with SQL Profiler . . . . . . . . . . . . . . . . . . . . . . . 93
Part II: Removing Bottlenecks with Tuning 141
Chapter 6: Choosing and Configuring Hardware . . . . . . . . . . . . . . . . . . . . . . . . . . . 143
Chapter 7: Tuning SQL Server Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 171
Chapter 8: Tuning the Schema . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 189
Chapter 9: Tuning T-SQL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 239
Part III: Preventative Measures and Baselining Performance
with Tools
319
Chapter 10: Capturing, Measuring, and Replaying a Workload Using
SQLProfiler 321
Chapter 11: Tuning Indexes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 353
Chapter 12: How Fast and Robust Is Your Storage? . . . . . . . . . . . . . . . . . . . . . . . . 409
Chapter 13: SQL Server 2005 Performance Dashboard Reports . . . . . . . . . . . . 471
Part IV: Roadmap to Server Performance 495
Chapter 14: Best Practices for Designing for Performance from the Start . . . 497
Chapter 15: Successful Deployment Strategies . . . . . . . . . . . . . . . . . . . . . . . . . 523
Index 539
www.it-ebooks.info
Wort ffirs.tex V3 - 12/19/2007 3:48pm Page ii
www.it-ebooks.info
Wort ffirs.tex V3 - 12/19/2007 3:48pm Page iii
Professional
SQL Server
®
2005
Performance Tuning
Steven Wort
Christian Bolton
Justin Langford
Michael Cape
Joshua J. Jin
Douglas Hinson
Haidong Ji
Paul A. Mestemaker
Arindam Sen
Wiley Publishing, Inc.
www.it-ebooks.info
Wort ffirs.tex V3 - 12/19/2007 3:48pm Page iv
Professional SQL Server
®
2005 Performance Tuning
Published by
Wiley Publishing, Inc.
10475 Crosspoint Boulevard
Indianapolis, IN 46256
www.wiley.com
Copyright © 2008 by Wiley Publishing, Inc., Indianapolis, Indiana
Published simultaneously in Canada
ISBN: 978-0-470-17639-9
Manufactured in the United States of America
10987654321
No part of this publication may be reproduced, stored in a retrieval system or transmitted in a ny form
or by any means, electronic, mechanical, photocopying, recording, scanning or otherwise, except as
permitted under Sections 107 or 108 of the 1976 United States Copyright Act, without either the prior
written permission of the Publisher, or authorization through payment of the appropriate per-copy fee
to the Copyright Clearance Center, 222 Rosewood Drive, Danvers, MA 01923, (978) 750-8400, fax (978)
646-8600. Requests to the Publisher for permission should be addressed to the Legal Department, Wiley
Publishing, Inc., 10475 Crosspoint Blvd., Indianapolis, IN 46256, (317) 572-3447, fax (317) 572-4355, or
online at
http://www.wiley.com/go/permissions
.
Limit of Liability/Disclaimer of Warranty: The publisher and the author make no representations or
warranties with respect to the accuracy or completeness of the contents of this work and specifically
disclaim all warranties, including without limitation warranties of fitness for a particular purpose. No
warranty may be created or extended by sales or promotional materials. The advice and strategies
contained herein may not be suitable for every situation. This work is sold with the understanding that
the publisher is not engaged in rendering legal, accounting, or other professional services. If professional
assistance is required, the services of a competent professional person should be sought. Neither the
publisher nor the author shall be liable for damages arising herefrom. The fact that an organization or
Website is referred to in this work as a citation and/or a potential source of further information does not
mean that the author or the publisher endorses the information the organization or Website may provide
or recommendations it may make. Further, readers should be aware that Internet Websites listed in this
work may have changed or disappeared between when this work was written and when it is read.
For general information on our other products and services or to obtain technical support, please contact
our Customer Care Department within the U.S. at (800) 762-2974, outside the U.S. at (317) 572-3993 or fax
(317) 572-4002.
Library of Congress Cataloging-in-Publication Data
Professional SQL server 2005 : performance tuning / Steven Wort [et al.].
p. cm.
Includes bibliographical references and index.
ISBN 978-0-470-17639-9 (paper/website)
1. SQL server. 2. Client/server computing. I. Wort, Steven.
QA76.9.C55P752 2008
005.75’85 dc22
2007045707
Trademarks: Wiley, the Wiley logo, Wrox, the Wrox logo, Wrox Programmer to Programmer, and related
trade dress are trademarks or registered trademarks of John Wiley & Sons, Inc. and/or its affiliates, in
the United States and other countries, and may not be used without written permission. SQL Server is
a registered trademark of Micosoft Corporation in the United States and/or other countries. All other
trademarks are the property of their respective owners. Wiley Publishing, Inc., is not associated with any
product or vendor mentioned in this book.
Wiley also publishes its books in a variety of electronic formats. Some content that appears in print may
not be available in electronic books.
www.it-ebooks.info
Wort fauth.tex V3 - 12/17/2007 1:57pm Page v
About the Authors
Steven Wort has been working with SQL Server for the past 14 years. He is currently a developer in the
Windows group at Microsoft where he works on performance and scalability issues on a large database
system. Steven has been at Microsoft for nearly 7 years, working in the Windows group for the past
2 years. Prior to this, Steven spent 2 years in the SQL Server group working on performance and scalabil-
ity. His first job at Microsoft was 3 years spent w orking in what is now CSS as an escalation engineer on
the SIE team. During this time Steven was able to travel the world working with some of Microsoft’s cus-
tomers on their performance and scalability problems. Before coming to Microsoft, Steven spent 20 years
working in the United Kingdom as a freelance consultant specializing in database a pplication develop-
ment. When Steven isn’t busy working, he can be found spending time with his family and enjoying
many fitness activities in the great outdoors of the Pacific Northwest.
Christian Bolton has been working with SQL Server since 1999 and in 2007 became a director and
database architect for Coeo Ltd, a Microsoft Certified Partner focused o n large-scale and complex SQL
Server projects in the United Kingdom. Prior to this, Christian worked for 5 years as a senior premier
field engineer for Microsoft UK, working with some of Microsoft’s biggest customers across EMEA. His
specialist areas are high availability, scalability, and performance tuning. Christian works out of London
and lives in the south of England with his wife and daughter. He can be contacted at
http://coeo.com
or through his blog at
http://sqlblogcasts.com/blogs/christian
.
Justin Langford has worked as a premier field engineer for Microsoft specializing in SQL Server for the
past 3 years. Much of this time has been focused on sharing best practices for operations and optimization
with some of the United Kingdom’s largest financial and government organizations. Justin previously
workedasaconsultantforaMicrosoftPartnerfocusing on upgrade, migration, and software deployment
projects for enterprise customers. Outside of work, Justin enjoys yacht racing, snowboarding, and has a
keen interest in classic British sports cars.
Michael Cape is a database developer with experience in a variety of industries. Those industries are
mortgage banking, pension administration, advertising, logistics, insurance, and labor management.
Michael holds a BSCS degree and got his start with database development with SQLBase from Gupta.
Michael also has 5 years experience with DB2, and has been working with SQL Server, starting with
version 7, for the last 7 years. Outside work, Michael spends time with his wife and two children. He also
enjoys golf, bicycling, fishing, and kite flying.
Joshua Jin works for the Intel Corporation. He is a certified SQL Server MCITP database administrator,
MCITP database developer, and MCITP business intelligence developer. He specializes in the
performance tuning of large-scale and high-volume SQL databases. Prior to working at Intel, he worked
on the largest Internet banking implementation in the United States, using SQL server as its database
engine. He can be reached at joshua_jin?@yahoo.com.
Douglas Hinson is an independent software and database consultant in the logistics and financial
industries, with an extensive SQL Server background. He has co-authored several Wrox books, including
Professional SQL Server 2005 Integration Services.
www.it-ebooks.info
Wort fauth.tex V3 - 12/17/2007 1:57pm Page vi
About the Authors
Haidong ‘‘Alex’’ Ji is a professional trainer and consultant specializing in SQL Server administra-
tion, performance tuning, high availability, and many other facets of SQL Server. In addition, he also
excels at database interoperability issues, having w orked extensively with Oracle and MySQL on Unix
and Linux. Haidong enjoys learning and sharing his expertise through technical writing, speaking,
consulting, training, and mentoring. He co-authored Professional SQL Server 2005 Integration Services
(Wrox Press) and Professional SQL Server 2005 Administration (Wrox Press). Haidong maintains a blog at
www.haidongji.com/category/technology/
. He can be contacted at Haidong.Ji@gmail.com.
Paul Mestemaker is a program manager at Microsoft on the SQL Server product team. During the
SQL Server 2005 product cycle, he worked closely with the new dynamic management views
on the SQL Server Engine team. Following the launch, Paul moved to the SQL Server Manageability
team to create tools on top of the new SQL platform technologies. He was influential in the release of
SQL Server 2005 Best Practices Analyzer, Performance Dashboard Reports, and SQL Server 2005 Service
Pack 2. He is now a member of the SQLCAT Best Practices team, where he works with subject mat-
ter experts across Microsoft and in the community to develop new rules for SQL BPA. Paul has been a
speaker at TechEd, PASS, Connections, and other Microsoft conferences. He blogs occasionally; you can
check it out here:
http://blogs.msdn.com/sqlrem/
.
Arindam Sen has worked with SQL Server for the past 8 years and has significant experience with
Siebel deployments using SQL Server databases. His interests lie in the area of high availability and
performance tuning. He is an MCSE, MCSA, MCAD, and MCDBA. He won the SQL Server innovator
award (SQL Server Magazine) in 2003 and 2004. He holds an engineering degree in electronics and an
MBA from Duke University.
vi
www.it-ebooks.info
Wort fcre.tex V3 - 12/17/2007 1:58pm Page vii
Credits
Executive Editor
Robert Elliott
Development Editor
Kelly Talbot
Technical Editors
Sunil Agarwal
Uttam Parui
Alan Doby
Stephen Olson
Production Editor
Dassi Zeidel
Copy Editor
Jack Peters
Editorial Manager
Mary Beth Wakefield
Production Manager
Tim Tate
Vice President and Executive Group Publisher
Richard Swadley
Vice President and Executive Publisher
Joseph B. Wikert
Project Coordinator, Cover
Lynsey Osborn
Proofreader
Ian Golder
Indexer
Robert Swanson
www.it-ebooks.info
Wort fack.tex V3 - 12/17/2007 1:58pm Page viii
Acknowledgments
We have to start by thanking our families. They have been infinitely patient and understanding while we
have spent many long hours working on this book. Thanks to all the team at Wiley Publishing. Robert
Elliot who got me started on this project, Kelly Talbot for his patience and guidance along the way, and
everyone else in the team who took the writings of the authors and turned them into this great book.
Thanks to all the technical editors. Thanks to everyone at Microsoft in the SQL Server group, on the
many discussion lists, and in CSS who were so willing to share their knowledge.
www.it-ebooks.info
Wort ftoc.tex V3 - 12/17/2007 2:00pm Page ix
Contents
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
www.it-ebooks.info
[...]... them Chapter 13 covers the SQL Server Performance Dashboard Dynamic Management Views The Dynamic Management Views (DMVs) in SQL Server 2005 are the source of a wealth of information about what is going on inside SQL Server In earlier versions of SQL Server, some of this information was made available in system tables In SQL Server 2005, the amount of information about what SQL Server is doing internally... size and performance is pushing more users against the limits of the out-of-the-box performance of SQL Server This means that more and more SQL Server users are having to start learning about a side of SQL Server that they never needed to know about — performance tuning The good news is that as with the out-of-the-box experience, the SQL Server team has spent a lot of time working on making SQL Server. .. knowledge of T -SQL, and know how to perform basic SQL Server and operating system administrative tasks With this basic knowledge you’re ready to get started on performance tuning SQL Server If you’re a SQL Server developer and have been working with SQL Server for 1 to 2 years, and you’re facing your first round of performance problems, then you’re ready to get started with this book If you’re a SQL Server. .. Configuring Hardware 143 Server Bottlenecks 143 Memory I/O CPU 144 144 144 Configuring the Server 145 Memory I/O CPU 147 153 162 Summary 170 Chapter 7: Tuning SQL Server Configuration 171 Considerations before Adjusting Server Level Settings Inspecting Current SQL Server Settings 171 172 Inspecting Server Settings with SQL Server Management Studio Inspecting Server Settings with Scripts Important Server Settings:... Chapter 1: Performance Tuning Chapter 2: Monitoring Server Resources with System Monitor Chapter 3: Monitoring SQL Server Resources with System Monitor Chapter 4: SQL Server Wait Types Chapter 5: Finding Problem Queries with SQL Profiler www.it-ebooks.info 3:09pm Page 1 Wort p01.tex www.it-ebooks.info V3 - 12/17/2007 3:09pm Page 2 Wort c01.tex V3 - 12/17/2007 Performance Tuning SQL Server 2005 works... Database Mirroring Performance x www.it-ebooks.info 54 2:00pm Page x Wort ftoc.tex V3 - 12/17/2007 2:00pm Contents Monitoring Wait Statistics Typical Performance Problems 55 55 Typical Disk Problems Memory Typical CPU Problems 56 56 57 Using SQL Server to Analyze Performance Logs Combining Performance Monitor Logs and SQL Profiler Trace Summary 59 64 65 Chapter 4: SQL Server Wait Types 67 SQL Server Waits... to start taking a methodical approach to performance tuning, to show you which tools to use and when, and to give you the knowledge you need to be a successful SQL Server performance tuner www.it-ebooks.info 7:11pm Page 3 Wort c01.tex V3 - 12/17/2007 Part I: Finding Bottlenecks when Something’s Wrong The Science of Performance Tuning Performance tuning SQL Server is a science In this chapter I will... perform all your SQL- related work Starting with a new Visual Studio solution/project-based approach, it includes: ❑ A server/ database object explorer ❑ The template explorer, which is an invaluable aid for writing T -SQL scripts ❑ The Query Analyzer interface ❑ SQL Server profiler ❑ Database Tuning Advisor (DTA) ❑ A shell to launch third-party tools SQL Server Performance Dashboard SQL Server Management... and Real-Life Performance 409 Performance Testing Stress Testing Real-Life Performance Putting It All Together 410 410 410 411 Storage Performance 412 Storage Performance Measuring Tools What Do You Want to Measure? Measuring I/O Performance Using SQLIO Storage Reliability 412 413 414 423 454 SQLIOSim Using SQLIOSim Best Practice for SQLIOSim Test Duration Running Other Tests Running SQLIOSim from... standard workloads for use in performance testing ❑ Chapter 11 covers missing indexes and the Database Tuning Advisor ❑ Chapter 12 covers storage subsystem performance and robustness and shows how you can use SQLIO and SQLIOSim to great effect ❑ Chapter 13 covers using SQL Server Performance Dashboard, which helps you find performance problems and is a great way to capture performance metrics By the end . Professional
SQL Server
®
2005 Performance Tuning
Enhance Your Knowledge
Advance Your Career
Professional SQL Server 2005
Performance Tuning
978-0-470-17639-9
This. func-
tionality, report, server administration, and security issues of SQL
Server 2005 Reporting Services.
Professional SQL Server 2005 CLR Programming:
Ngày đăng: 16/02/2014, 13:20
Xem thêm: Tài liệu Professional SQL Server 2005 Performance Tuning doc, Tài liệu Professional SQL Server 2005 Performance Tuning doc