Table of Contents About the Author About the Technical Reviewer Acknowledgments Introduction Part I: SQL Server Internals Chapter 1: How SQL Server Works TDS/Network Protocols How Work Is Performed SQLOS Schedulers Workers SQL Server on Linux Query Optimization Parsing and Binding Simplification Trivial Plan Optimization Transformation Rules The Memo Full Optimization Cost Estimation Statistics Plan Caching Query Execution Operators Data Access Operators Aggregations Joins Nested Loops Join Merge Join Hash Join Parallelism Updates Memory Grants Locks and Latches Summary Chapter 2: SQL Server on Linux Microsoft Announcements A Bit of History SQLOS Project Helsinki Drawbridge SQLPAL Summary Part II: Design and Configuration Chapter 3: SQL Server Configuration Statistics Update Standard Automatic Statistics Update Trace Flag 2371 tempdb Configuration Query Optimizer Hotfix Servicing Model max degree of parallelism cost threshold for parallelism Instant File Initialization Cardinality Estimator optimize for ad hoc workloads SQL Server Enterprise Edition Memory Configuration Lock Pages in Memory backup compression default query governor cost limit blocked process threshold Advanced Trace Flags Configuring SQL Server on Linux Using Environment Variables Performance Best Practices Memory and the Out-of-Memory Killer Kernel Settings Additional Configurations Summary Chapter 4: tempdb Troubleshooting and Configuration DML Contention Describing tempdb Latch Contention Fixing tempdb Latch Contention Using Multiple Data Files Trace Flags 1117 and 1118 SQL Server 2016 Enhancements What Is New in SQL Server 2019 Memory-Optimized tempdb Metadata tempdb Events DDL Contention tempdb Spill Warnings Sort Warning Hash Warning Exchange Warning Monitoring Disk Space Summary Part III: Monitoring Chapter 5: Analyzing Wait Statistics Introduction Wait Information sys.dm_os_wait_stats sys.dm_exec_session_wait_stats Extended Events system_health Extended Event Session Example: Analyzing CXPACKET Waits Latches and Spinlocks Common Waits CXPACKET CXCONSUMER PAGELATCH_* and PAGEIOLATCH_* ASYNC_NETWORK_IO SOS_SCHEDULER_YIELD THREADPOOL PREEMPTIVE_* OLEDB IO_COMPLETION WRITELOG Timer Wait Types What Is New on SQL Server 2019 Blocking In-Memory OLTP Summary Chapter 6: The Query Store Why Is a Query Slow? Plan Changes How the Query Store Can Help Plan Regressions SQL Server Upgrades Application/Hardware Changes Identify Expensive Queries Identify Ad Hoc Workloads Architecture Enabling, Purging, and Disabling the Query Store Using the Query Store Performance Troubleshooting Incomplete Queries Force Failure Wait Statistics Catalog Views Live Query Statistics Summary Part IV: Performance Tuning and Troubleshooting Chapter 7: SQL Server In-Memory Technologies In-Memory OLTP Enhancements After the Initial Release Memory-Optimized Tables Indexes Natively Compiled Modules Changing Tables and Natively Compiled Modules Native Compilation Memory-Optimized Table Variables Current Limitations Columnstore Indexes Examples Operational Analytics Using Disk-Based Tables Using Memory-Optimized Tables Summary Chapter 8: Performance Troubleshooting Performance Counters Comparing Batches and Transactions Log Growths Data File(s) Size (KB) Page Reads/Sec Page Writes/Sec Page Life Expectancy Buffer Cache Hit Ratio % Processor Time Processor Queue Length Latches Locks LogicalDisk and PhysicalDisk SQL Compilations/Sec and Recompilations/Sec Memory Grants Processes Blocked Log Flush Counters Checkpoint Pages/Sec Memory Manager sys.dm_os_performance_counters Dynamic Management Views and Functions sys.dm_io_virtual_file_stats sys.dm_os_volume_stats sys.dm_db_index_usage_stats sys.dm_exec_query_stats sys.dm_db_index_physical_stats sys.dm_exec_query_optimizer_info sys.dm_os_sys_info sys.dm_os_windows_info sys.dm_os_host_info SQL Trace/Extended Events SQL Server Data Collector Operator-Level Performance Statistics Trace Flags on Plans Summary Chapter 9: Indexing How SQL Server Uses Indexes Where to Use Indexes Index Usage Validation Index Maintenance Heaps Clustered Indexes Nonclustered Indexes Filtered Indexes Working with Indexes The Missing Indexes Feature The Database Engine Tuning Advisor Summary Chapter 10: Intelligent Query Processing Batch Mode Adaptive Joins Memory Grant Feedback Interleaved Execution Batch Mode on Rowstore Table Variable Deferred Compilation Scalar UDF Inlining Approximate Count Distinct Summary Chapter 11: SQL Server Storage Storage Types Flash-Based Storage Database Configuration Database Files Fragmentation Virtual Log Files Compression Metrics and Performance Resource Monitor Diskspd SQLIOSim DMVs/DMFs Volume Configuration RAID Levels RAID 0 RAID 1 RAID 5 RAID 6 RAID 10 Query Processing Summary Index Design and configure SQL Server instances and databases in support of high-throughput, mission-critical applications providing consistent response times in the face of variations in numbers of users and query volumes. In this new edition, with over 100 pages of additional content, every original chapter has been updated for SQL Server 2019, and the book also includes two new chapters covering SQL Server on Linux and Intelligent Query Processing. This book shows you how to configure SQL Server and design your databases to support a given instance and workload. You will learn advanced configuration options, in-memory technologies, storage and disk configuration, and more, all aimed toward enabling your desired application performance and throughput. Configuration doesn't stop with implementation. Workloads change over time, and other impediments can arise to thwart desired performance. High Performance SQL Server covers monitoring and troubleshooting to aid you in detecting and fixing production performance problems and minimizing application outages. You will learn about a variety of tools, ranging from the traditional wait analysis methodology to the query store or indexing, and you will learn how improving performance is an iterative process. This book is an excellent complement to query performance tuning books and provides the other half of what you need to know by focusing on configuring the instances on which mission-critical queries are executed. What You Will Learn Understand SQL Server's database engine and how it processes queries Configure instances in support of high-throughput applications Provide consistent response times to varying user numbers and query volumes Design databases for high-throughput applications with focus on performance Record performance baselines and monitor SQL Server instances against them Troubleshot and fix performance problems Who This Book Is For SQL Server database administrators, developers, and data architects. The book is also of use to system administrators who are managing and are responsible for the physical servers on which SQL Server instances are run.