Pro SQL Server Internals 2nd Edition Dmitri Korotkevitch Ebook All Chapters PDF
Pro SQL Server Internals 2nd Edition Dmitri Korotkevitch Ebook All Chapters PDF
com
https://textbookfull.com/product/pro-sql-server-
internals-2nd-edition-dmitri-korotkevitch/
https://textbookfull.com/product/expert-sql-server-in-memory-oltp-2nd-
edition-dmitri-korotkevitch/
textbookfull.com
https://textbookfull.com/product/sql-server-internals-in-memory-oltp-
inside-the-sql-server-2016-hekaton-engine-2nd-edition-kalen-delaney/
textbookfull.com
https://textbookfull.com/product/jacaranda-maths-quest-
units-1-2-essential-mathematics-11-for-queensland-1st-edition-mark-
barnes/
textbookfull.com
https://textbookfull.com/product/principles-of-information-security-
fifth-edition-mattord/
textbookfull.com
https://textbookfull.com/product/foundations-of-deep-reinforcement-
learning-theory-and-practice-in-python-first-edition-laura-graesser/
textbookfull.com
https://textbookfull.com/product/chemical-reaction-engineering-and-
reactor-technology-second-edition-tapio-o-salmi-author/
textbookfull.com
T HE E X P ER T ’S VOIC E ® IN S QL
Dmitri Korotkevitch
Pro SQL Server Internals, Second Edition
Dmitri Korotkevitch
Tampa
Florida, USA
ISBN-13 (pbk): 978-1-4842-1963-8 ISBN-13 (electronic): 978-1-4842-1964-5
DOI 10.1007/978-1-4842-1964-5
Library of Congress Control Number: 2016959812
Copyright © 2016 by Dmitri Korotkevitch
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.
Managing Director: Welmoed Spahr
Lead Editor: Laura Berendson
Technical Reviewer: Victor Isakov and Mike McQuillan
Editorial Board: Steve Anglin, Pramila Balan, Laura Berendson, Aaron Black, Louise Corrigan,
Jonathan Gennick, Todd Green, Robert Hutchinson, Celestin Suresh John, Nikhil Karkal,
James Markham, Susan McDermott, Matthew Moodie, Natalie Pao, Gwenan Spearing
Coordinating Editor: Jill Balzano
Copy Editor: April Rondeau
Compositor: SPi Global
Indexer: SPi Global
Artist: SPi Global
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 [email protected],
or visit www.springer.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.
For information on translations, please e-mail [email protected], or visit www.apress.com.
Apress and friends of ED books may be purchased in bulk for academic, corporate, or promotional use. eBook
versions and licenses are also available for most titles. For more information, reference our Special Bulk
Sales–eBook Licensing web page at www.apress.com/bulk-sales.
Any source code or other supplementary materials referenced by the author in this text are available to
readers at www.apress.com. For detailed information about how to locate your book’s source code, go to
www.apress.com/source-code/. Readers can also access source code at SpringerLink in the Supplementary
Material section for each chapter.
Printed on acid-free paper
To my family. Thank you for letting me disappear behind the keyboard
and ignore all my chores and duties!
Contents at a Glance
v
■ CONTENTS AT A GLANCE
vi
■ CONTENTS AT A GLANCE
vii
Contents
ix
■ CONTENTS
x
■ CONTENTS
xi
Visit https://textbookfull.com
now to explore a rich
collection of eBooks, textbook
and enjoy exciting offers!
■ CONTENTS
xii
■ CONTENTS
xiii
■ CONTENTS
xiv
■ CONTENTS
xv
■ CONTENTS
xviii
■ CONTENTS
xix
■ CONTENTS
xxi
Visit https://textbookfull.com
now to explore a rich
collection of eBooks, textbook
and enjoy exciting offers!
■ CONTENTS
xxii
About the Author
xxiii
About the Technical Reviewers
Victor Isakov is a database architect and Microsoft certified trainer. He provides consulting and
training services globally to various organizations in the public, private, and NGO sectors, and
has been involved in different capacities at various international events and conferences.
He has authored a number of books on SQL Server and worked closely with Microsoft to develop the
new generation of SQL Server 2005 certification and the Microsoft Official Curriculum for both ILT and
e-learning.
Specialties include Microsoft SQL Server; Microsoft analysis services; designing database solutions; re-
factoring database solutions; performance tuning database solutions; and SQL Server training.
xxv
Acknowledgments
First and foremost, I am enormously grateful to my technical reviewers, Victor Isakov and Mike McQuillan.
Their suggestions and comments were extremely helpful and dramatically improved the quality of the book.
It would have been impossible for me to complete the project without their help.
The same applies to the entire Apress team and especially to Jill Balzano, Douglas Pundick, and April
Rondeau. Special thanks go to Jonathan Gennick, who is keeping the series alive.
I would also like to thank Tom LaRock, who reviewed the first edition of the book. Even though he was
unable to participate in this project, you can see his influence all over the place.
Next, I would like to thank Thomas Grohser, who helped me to write Chapter 5 and provided great
feedback on a few other topics. He is a Microsoft Data Platform MVP with more than 20 years of experience
working with SQL Server. He specializes in designing and building SQL Server solutions that focus on high
availability, disaster recovery, scalability, security, and manageability.
I would like to thank Niko Neugebauer, who is the one of the world’s best experts in columnstore
indexes and data warehousing. Niko reviewed Chapters 33 and 34 and gave me great feedback on them.
Niko is a Microsoft Data Platform MVP and has, perhaps, the best columnstore indexes–related blog
on the Internet, which can be found at http://www.nikoport.com/columnstore. He also published
the Columnstore Indexes Scripts Library at GitHub, which you can access at https://github.com/
NikoNeugebauer/CISL.
The same thanks apply to Dmitry Pilugin for his help with Chapters 3 and 29. Dmitry is one of very few
people outside of Microsoft who knows how Query Optimizer actually works, and he generously reviewed
those chapters for me. You can read Dmitry’s blog about Query Processor at http://www.queryprocessor.com.
Obviously, a book about SQL Server would be meaningless without the product itself. I would like to
thank the entire Microsoft team for all their hard work and the wonderful platform they created. Special
thanks go to Jos de Bruijn, Sunil Agarwal, Ajay Jagannathan, Gjorgji Gjeorgjievski, Alexey Eksarevskiy, Borko
Novakovic, Arvind Shyamsundar, and many others who patiently answered my questions.
I would like to thank Ian Stirk and Nazanin Mashayekh for the great feedback on the first-edition
content. It helped me to improve the quality of this edition.
Finally, I would like to thank all my friends from the SQL Server community for their support and
encouragement. It is impossible to list everyone here, but there is one group of people I want to thank in
particular. Those are my Nepali friends: Dibya Shakya, Shree Khanal, Ravi Chandra Koirala, and Raghu
Bhandari. It was very motivating to meet such a wonderful community!
Thank you very much! It was a pleasure and honor to work with all of you!
xxvii
Introduction
Four years ago, when I had just started to work on the first edition of Pro SQL Server Internals, many people
asked me, “Why have you decided to write yet another book on the subject? There are plenty of other
Internals books already published.” It was—and, as a matter of fact, still is—a very valid question, which I feel
obligated to answer.
I set myself two goals when I started to work on the series. First, I wanted to explain how SQL Server
works in the most practical way, demonstrating dependencies between particular aspects of SQL Server
Internals and the behavior of your systems. Perhaps it deserves some explanation.
There is a joke in the SQL Server community: “How do you distinguish between junior- and senior-level
database professionals? Just ask them any question about SQL Server. The junior-level person gives you the
straight answer. The senior-level person, on the other hand, always answers, ‘It depends.’”
As strange as it sounds, that is correct. SQL Server is a very complex product with a large number of
components that depend on each other. You can rarely give a straight yes or no answer to any question. Every
decision comes with its own set of strengths and weaknesses and leads to consequences that affect other
parts of the system.
Pro SQL Server Internals covers on what, exactly, “it depends.” I wanted to give you enough information
about how SQL Server works and to show you various examples of how specific database designs and code
patterns affect SQL Server’s behavior. I tried to avoid generic suggestions based on best practices. Even
though those suggestions are great and work in a large number of cases, there are always exceptions. I hope
that, after you read this series, you will be able to recognize those exceptions and make decisions that benefit
your particular systems.
My second goal was based on the strong belief that the line between database administration and
development is very thin. It is impossible to be a successful database developer without knowledge of SQL
Server Internals. Similarly, it is impossible to be a successful database administrator without the ability
to design efficient database schema and write good T-SQL code. That knowledge helps both developers
and administrators to better understand and collaborate with each other, which is especially important
nowadays in the age of agile development and multi-terabyte databases.
This belief came from my personal experience. I started my career in IT as an application developer,
slowly moving to backend and database development over the years. At some point, I found that it was
impossible to write good T-SQL code unless I understood how SQL Server executed it. That discovery forced
me to learn SQL Server Internals, and it led to a new life in which I design, develop, and tune various database
solutions. I do not write client applications anymore; however, I perfectly understand the challenges that
application developers face when they deal with SQL Server. I have “been there and done that.”
My biggest challenge during the transition to the Internals world was to find good learning materials.
There were plenty of good books; however, all of them had a clear separation in their content. They expected
the reader to be either developer or database administrator—never both. I tried to avoid that separation
in this book. Obviously, some of the chapters are more DBA-oriented, while others lean more toward
developers. Nevertheless, I hope that anyone who is working with SQL Server will find the content useful.
You should not, however, consider Pro SQL Server Internals to be a SQL Server tutorial. Nor is it a
beginner-level book. I expect you to have previous experience working with relational databases, preferably
with SQL Server. You need to know RDBMS concepts, be familiar with different types of database objects,
and be able to understand SQL code if you want to get the most out of this series.
xxix
Random documents with unrelated
content Scribd suggests to you:
Kulkiessaan edelleen Ugambia ylös tuli hän kaksi päivää
myöhemmin suureen kylään. Päällikkö, häijynnäköinen veitikka —
hänellä oli teräviksi viilatut hampaat, jotka usein ilmaisevat
ihmissyöjää — otti hänet vastaan näennäisen ystävällisesti.
Tuskin oli hän lähtenyt päällikön luota, kun tämä kutsui puheilleen
kaksi soturia, joille hän kuiskasi muutamia määräyksiä. Hetkeä
myöhemmin nuo sileäihoiset mustat hahmot kiitivät pitkin joenvartta
ylöspäin itään.
"Sinä olet tehnyt hyvin", vastasi valkoinen mies, "ja sinä saat
pyssyn ja ammuksia, olkoonpa hän ystävä tai vihollinen, kunhan vain
pysyt puolellani."
Kuolemantanssi
Kuolema!
Jane ei saisi milloinkaan tietää, miten hän kuoli. Siitä hän kiitti
taivasta, ja hän oli kiitollinen siitäkin, että ainakin Jane oli turvassa
maailman suurimman kaupungin sydämessä. Turvassa herttaisten ja
rakastavien ystävien keskellä, jotka tekisivät parhaansa
keventääkseen hänen kuormaansa.
Mutta poika!
Mikä oli tuonut eläimen hänen luokseen? Se, että Sheeta oli tullut,
oli hyvänä enteenä siitä, mitä se saattoi tehdä. Mutta kun Tarzan
koetti saada Sheetan kalvamaan siteet poikki, ei tuo suuri eläin
näyttänyt voivan käsittää, mitä häneltä odotettiin, vaan nuoleskeli
sensijaan vangin ranteita ja käsivarsia.
Hänellä oli hyvin vähän toivoa, että Sheeta palaisi, sillä jos tämä
olisi aikonut puolustaa häntä kaikkia tulijoita vastaan, olisi se jäänyt
hänen viereensä kuullessaan villien lähestyvän ulkoapäin.
Hän astui taas askeleen nuorta naista kohti. Hänen ilkeät kasvonsa
olivat vääristyneet raivosta ja kiihkosta. Hän hyppäsi villieläimen
tavoin nuoren naisen kimppuun, iski vahvat sormensa hänen
kurkkuunsa ja työnsi häntä taaksepäin makuusijaa kohti.
"Mitä tarkoitat, kun tulet tänne ilman lupaa?" huudahti hän. "Mene
ulos!"
"Hen luule mine oli hupsu", sanoi hän. "Hen oli itse hupsu. Mine
osa franska."
Andersson irvisti.
"Te oli hyve minulle", selitti ruotsalainen. "Hen kohtele minu kuin
paha koira. Mine auta teite, frouva. Teide pite odotta — mine auta
teite. Mine oli monta kerta teelle lensirannikko."
"Mutta kuinka voitte auttaa minua, Sven", kysyi Jane, "kun kaikki
nämä miehet ovat meitä vastaan?"
Vaikka Jane epäili kokin kykyä auttaa häntä todenteolla, oli hän
tälle kuitenkin syvästi kiitollinen siitä, mitä hän jo oli tehnyt. Tunne,
että hänellä oli näiden vihollisten joukossa ystävä, toi hänelle
ensimmäisen lohdutuksen säteen ja huojensi raskaiden aavistusten
taakkaa, jotka olivat vaivanneet häntä Kincaidin pitkän matkan
aikana.
"Te teke, mite mine sano", sanoi Andersson äreästi. "Jos mine
auta teite, te ei saa olla hupsu."
Vaikka oli täysikuu, oli pikku joen pinta aivan musta. Jättiläispuut
kaartuivat likekkäin olevien rantojen yli, yhtyen suureksi holviksi joen
keskipalkalla. Kauniisti kaareutuvilta oksilta riippui tuuheata
sammalta, ja äärettömiä köynnöskasveja kiipeili rehevän
yltäkylläisesti maasta korkeimmille oksille saakka, laskeutuen
kiemurtelevina silmukkoina melkein veden tyyneen pintaan asti.
Ruotsalainen