Grant Fritchey
SQL Server 2017 Query Performance Tuning Troubleshoot and Optimize Query Performance 5th ed.
Grant Fritchey
Grafton, Massachusetts, USA
Any source code or other supplementary material referenced by the author in this book is available to readers on GitHub via the books product page, located at www.apress.com/9781484238875 . For more detailed information, please visit www.apress.com/source-code .
ISBN 978-1-4842-3887-5 e-ISBN 978-1-4842-3888-2
https://doi.org/10.1007/978-1-4842-3888-2
Library of Congress Control Number: 2018955582
Grant Fritchey 2018
This work is subject to copyright. All rights are reserved by the Publisher, whether the whole or part of the material is concerned, specifically the rights of translation, reprinting, reuse of illustrations, recitation, broadcasting, reproduction on microfilms or in any other physical way, and transmission or information storage and retrieval, electronic adaptation, computer software, or by similar or dissimilar methodology now known or hereafter developed.
Trademarked names, logos, and images may appear in this book. Rather than use a trademark symbol with every occurrence of a trademarked name, logo, or image we use the names, logos, and images only in an editorial fashion and to the benefit of the trademark owner, with no intention of infringement of the trademark. The use in this publication of trade names, trademarks, service marks, and similar terms, even if they are not identified as such, is not to be taken as an expression of opinion as to whether or not they are subject to proprietary rights.
While the advice and information in this book are believed to be true and accurate at the date of publication, neither the authors nor the editors nor the publisher can accept any legal responsibility for any errors or omissions that may be made. The publisher makes no warranty, express or implied, with respect to the material contained herein.
Distributed to the book trade worldwide by Springer Science+Business Media New York, 233 Spring Street, 6th Floor, New York, NY 10013. Phone 1-800-SPRINGER, fax (201) 348-4505, e-mail orders-ny@springer-sbm.com, or visit www.springeronline.com. Apress Media, LLC is a California LLC and the sole member (owner) is Springer Science + Business Media Finance Inc (SSBM Finance Inc). SSBM Finance Inc is a Delaware corporation.
To my family. Thank you.
Introduction
Technology is changing all the time, faster and faster. New functionality is introduced in Azure SQL Database on an almost weekly schedule, and SQL Server itself has gone through two releases since the last edition of this book was published. New styles of databases are introduced all the time. With all this change, the question immediately in front of you should be, do we still need to do query tuning?
The answer is a very short and resounding, yes.
With all the functionality and capability built into SQL Server and the Azure Data Platform, not only is query tuning still an important skill, it actually becomes a way to save your organization money. Knowing how to make a query run faster so that fewer resources are needed literally becomes a way to reduce costs within a platform-as-a-service offering such as Azure SQL Database.
However, its not just about money. The code generated by object-relational mapping tools such as Entity Framework can be fantastic, until it isnt. Then, youll be working on creating custom scripts and generating data structures and indexes and all the rest of traditional query performance tuning.
While technology has certainly moved fast and far, there is still a fundamental need to get queries to run faster and do more with less overhead on your servers. Thats where this book comes into play. This is a resource that you can use to ensure that youre using all the tools in your hands to ensure that the databases you build, develop, and maintain will continue to run faster.
Who Is This Book For?
If you write or generate T-SQL, youre going to need to make it run faster. So, this book is for data analysts, developers, coders, database designers, database developers, and that last bastion of protection for the companys information, the database administrator. Youll all need at one point or another to understand how indexes work, where to track down performance metrics, and methods and mechanisms to ensure that your queries run as fast as they can.
The code for the book is available from Apress.com. If you have questions, want suggestions, or just need a little help, you can get in touch with me at grant@scarydba.com .
Acknowledgments
The poor editors at Apress have to put up with me and my bad scheduling, so first and foremost, thanks to Jill Balzano and Jonathan Gennick. To say I couldnt have done it without you doesnt begin to cover it. Ive said it before and Ill say it again here, publicly and forever in print, Joe Sack is my hero. Thanks for everything, Joe.
About the Author and About the Technical Reviewer
About the Author
Grant Fritchey
, Microsoft Data Platform MVP, has more than 20 years of experience in IT. That time was spent in technical support, development, and database administration. He currently works as a product evangelist at Red Gate Software. Grant writes articles for publication at SQL Server Central and Simple-Talk. He has published books, including SQL Server Execution Plans and SQL Server 2012 Query Performance Tuning (Apress). He has written chapters for Beginning SQL Server 2012 Administration (Apress) , SQL Server Team-based Development, SQL Server MVP Deep Dives Volume 2, Pro SQL Server 2012 Practices (Apress) , and Expert Performance Indexing in SQL Server (Apress). Grant currently serves as the president on the board of directors of the PASS organization, the leading source of educational content and training on the Microsoft data platform.
About the Technical Reviewer
Joseph Sack
is a principal program manager at Microsoft, focusing on query processing for Azure SQL Database and SQL Server. He has worked as a SQL Server professional since 1997 and has supported and developed for SQL Server environments in financial services, IT consulting, manufacturing, retail, and the real estate industry.
Joe joined Microsoft in 2006 and was a SQL Server premier field engineer for large retail customers in Minneapolis, Minnesota. He was responsible for providing deep SQL Server advisory services, training, troubleshooting, and ongoing solutions guidance. In 2006 Joe earned the Microsoft Certified Master: SQL Server 2005 certification, and in 2008 he earned the Microsoft Certified Master: SQL Server 2008 certification. In 2009 he took over responsibility for the entire SQL Server Microsoft Certified Master program and held that post until 2011.
He left Microsoft in late 2011 to join SQLskills, working as a principal consultant. During that time, he co-instructed for various training events and was a consultant for customer performance tuning engagements. He recorded 13 Pluralsight courses, including