SQL Server Advanced Troubleshooting and Performance Tuning
by Dmitri Korotkevitch
Copyright 2022 Dmitri Korotkevitch. All rights reserved.
Printed in the United States of America.
Published by OReilly Media, Inc., 1005 Gravenstein Highway North, Sebastopol, CA 95472.
OReilly books may be purchased for educational, business, or sales promotional use. Online editions are also available for most titles (http://oreilly.com). For more information, contact our corporate/institutional sales department: 800-998-9938 or corporate@oreilly.com .
- Acquisitions Editor: Andy Kwan
- Development Editor: Sarah Grey
- Production Editor: Beth Kelly
- Copyeditor: Audrey Doyle
- Proofreader: Piper Editorial Consulting, LLC
- Indexer: Potomac Indexing, LLC
- Interior Designer: David Futato
- Cover Designer: Karen Montgomery
- Illustrator: Kate Dullea
Revision History for the First Edition
- 2022-05-13: First Release
See http://oreilly.com/catalog/errata.csp?isbn=9781098101923 for release details.
The OReilly logo is a registered trademark of OReilly Media, Inc. SQL Server Advanced Troubleshooting and Performance Tuning, the cover image, and related trade dress are trademarks of OReilly Media, Inc.
The views expressed in this work are those of the author, and do not represent the publishers views. While the publisher and the author have used good faith efforts to ensure that the information and instructions contained in this work are accurate, the publisher and the author disclaim all responsibility for errors or omissions, including without limitation responsibility for damages resulting from the use of or reliance on this work. Use of the information and instructions contained in this work is at your own risk. If any code samples or other technology this work contains or describes is subject to open source licenses or the intellectual property rights of others, it is your responsibility to ensure that your use thereof complies with such licenses and/or rights.
978-1-098-10192-3
[LSI]
Preface
Its been a few years since I published my last book. Many things have changed since then. Several SQL Server versions have been released. The product has become more mature, offering cross-OS support and true cloud-friendly capabilities. Nevertheless, I did not think it was the right time to publish the new edition of Pro SQL Server Internals (Apress).
There were a couple reasons for that. As great as the new features were, they did not change the way the product works fundamentally. Most of the content from my old books could be applied to SQL Server 2017, SQL Server 2019, and even upcoming SQL Server 2022 releases. More importantly, I wanted to write the book in a different way.
Perhaps, I need to elaborate. As some of you may know, Ive been delivering SQL Server courses for many years, and I considered my books as supplementary materials for them. In fact, I started to write because I wanted to present the content in a more structured, nonPower Point format. I am glad that my readers liked it and found the books especially useful.
All my courses focused on SQL Server Internals. Ive always believed that any professional needs to know their tools to be successful. I taught my audience how SQL Server works, helping them to use this knowledge and build efficient systems. Over time, however, I found that troubleshooting and performance tuning became the most popular topic in my classespeople like when I start with the problem and then explain why it occurs.
As I changed the way I teach, I also decided to change the way I write. Now, 18 months later, you look at the result of that decision. Personally, I like the outcome. It is still about SQL Server Internals, although, it is concise and more practical than any of my previous works. It would give you enough knowledge to detect and address key system issues, reducing the information overload. It will also point you in the right direction if youd like to learn more.
This book describes the methodology used by many high-end SQL Server consultants. Youll learn how to collect and analyze the data, detecting bottlenecks and inefficiencies. More importantly, Ill show you how to look at the system holistically and avoid tunnel vision.
The content is not SQL Serverversion specific. With a few exceptions, it would apply to all versions from SQL Server 2005 to soon-to-be-released SQL Server 2022 and beyond. It also works for managed SQL Server services running in the cloud.
Who This Book Is For
When people ask me about the target audience of my books, I always say that I write for database professionals. I purposefully use that termI believe that the line that separates database administrators, database developers, and even application developers is quite thin. It is impossible to be successful in IT nowadays if you limit yourself and dont expand your area of expertise and responsibilities.
It is especially important with the DevOps culture. The teams become the owners of their destinies, developing and maintaining solutions on their own. It becomes common for developers to troubleshoot performance issues that may be caused by the infrastructure or inefficient database code.
In the end, if you work with SQL Server in any roleon-premises and in the cloudthis book is for you. I hope that youll find useful information regardless of what your job title is.
Thank you again for your trust in me and I hope you will enjoy reading it as much as I did while writing it for you!
Overview of the Chapters
This book consists of 16 chapters structured in the following way:
- , provides several guidelines and best practices on how to choose the hardware and configure SQL Server instances.
- , discusses a vital SQL Server componentSQLOSand introduces you to the common troubleshooting technique called Wait Statistics. This chapter is the cornerstone for the book content.
- , gives you an overview of how SQL Server works with I/O subsystem and shows you how to analyze and troubleshoot its performance.
- , talks about a few methods that allow you to detect nonoptimized queries and choose targets for further query tuning.
- , explains how SQL Server works with data in the database, and shares the set of query tuning tips and techniques.
- , discusses most common causes that lead to high CPU load and the ways to mitigate CPU bottlenecks.
- , covers memory configuration in SQL Server and shows you how to analyze memory usage and address memory-related issues.
- , talks about SQL Servers concurrency model and how to remediate blocking and deadlocks in the system.
- , discusses
tempdb
utilization, and configuration best practices. It also provides a few guidelines on the optimal usage of temporary objects and shows how to mitigate common tempdb
bottlenecks. - , talks about latches in SQL Server. It covers several cases when they may become the problem and the ways to address that.
- , provides an overview of how SQL Server works with a transaction log and explains how to deal with common bottlenecks and error conditions.
- , covers the most frequently used SQL Server High Availability technology and common issues you may encounter in that setup.
- , discusses several common wait types that have not been covered in other chapters.
- , gives you a few tips on how to detect inefficiencies in database design and also evaluate usage and health of the indexes.