| About the Author |
|
xv | |
| About the Technical Reviewers |
|
xvii | |
| Acknowledgments |
|
xix | |
| Introduction |
|
xxi | |
|
Part I Foundations of Wait Statistics Analysis |
|
|
1 | (100) |
|
Chapter 1 Wait Statistics Internals |
|
|
3 | (22) |
|
A Brief History of Wait Statistics |
|
|
4 | (2) |
|
|
|
6 | (3) |
|
Schedulers, Tasks, and Worker Threads |
|
|
9 | (10) |
|
|
|
10 | (1) |
|
|
|
11 | (1) |
|
|
|
12 | (1) |
|
|
|
13 | (3) |
|
|
|
16 | (1) |
|
|
|
17 | (2) |
|
|
|
19 | (4) |
|
|
|
23 | (2) |
|
Chapter 2 Querying SQL Server Wait Statistics |
|
|
25 | (38) |
|
|
|
26 | (3) |
|
|
|
29 | (4) |
|
Understanding sys.dm_os_waiting_tasks |
|
|
29 | (2) |
|
Querying sys.dm_os_waiting_tasks |
|
|
31 | (2) |
|
|
|
33 | (3) |
|
Understanding sys.dm_exec_requests |
|
|
33 | (2) |
|
Querying sys.dm_exec_requests |
|
|
35 | (1) |
|
Sys.dm_exec_session_wait_stats |
|
|
36 | (2) |
|
Combining DMVs to Detect Waits Right Now |
|
|
38 | (5) |
|
Viewing Wait Statistics Using Perfmon |
|
|
43 | (2) |
|
Capturing Wait Statistics Using Extended Events |
|
|
45 | (12) |
|
Capture Wait Statistics Information for a Specific Query |
|
|
46 | (11) |
|
Analyzing Wait Statistics on a Per-Query Basis Using Execution Plans |
|
|
57 | (4) |
|
|
|
61 | (2) |
|
Chapter 3 The Query Store |
|
|
63 | (12) |
|
|
|
63 | (1) |
|
|
|
64 | (1) |
|
How Wait Statistics Are Processed in the Query Store |
|
|
65 | (3) |
|
Accessing Wait Statistics Through the Query Store Reports |
|
|
68 | (2) |
|
Accessing Wait Statistics Through the Query Store DMVs |
|
|
70 | (3) |
|
|
|
73 | (2) |
|
Chapter 4 Building a Solid Baseline |
|
|
75 | (26) |
|
|
|
76 | (5) |
|
Visualizing Your Baselines |
|
|
78 | (1) |
|
Baseline Types and Statistics |
|
|
79 | (2) |
|
|
|
81 | (1) |
|
|
|
81 | (1) |
|
|
|
81 | (1) |
|
Focus on the Big Measurement Changes |
|
|
81 | (1) |
|
|
|
82 | (1) |
|
Building a Baseline for Wait Statistics Analysis |
|
|
82 | (9) |
|
|
|
86 | (1) |
|
|
|
87 | (2) |
|
Using SQL Server Agent to Schedule Measurements |
|
|
89 | (2) |
|
Wait Statistics Baseline Analysis |
|
|
91 | (8) |
|
|
|
99 | (2) |
|
|
|
101 | (272) |
|
Chapter 5 CPU-Related Wait Types |
|
|
103 | (36) |
|
|
|
103 | (11) |
|
What Is the Cxpacket Wait Type? |
|
|
104 | (3) |
|
Lowering Cxpacket Wait Time by Tuning the Parallelism Configuration |
|
|
107 | (4) |
|
Lowering Cxpacket Wait Time by Resolving Skewed Workloads |
|
|
111 | (1) |
|
Introduction of the Cxconsumer Wait Type in SQL Server 2016 SP2 and 2017 |
|
|
112 | (1) |
|
|
|
113 | (1) |
|
|
|
114 | (9) |
|
What Is the Sos_Scheduler_Yield Wait Type? |
|
|
114 | (3) |
|
Lowering Sos_Scheduler_Yield Waits |
|
|
117 | (5) |
|
Sos_Scheduler_Yield Summary |
|
|
122 | (1) |
|
|
|
123 | (16) |
|
What Is the Threadpool Wait Type? |
|
|
123 | (3) |
|
|
|
126 | (4) |
|
Gaining Access to Our SQL Server During Threadpool Waits |
|
|
130 | (2) |
|
Lowering Threadpool Waits Caused by Parallelism |
|
|
132 | (2) |
|
Lowering Threadpool Waits Caused by User Connections |
|
|
134 | (3) |
|
|
|
137 | (2) |
|
Chapter 6 IO-Related Wait Types |
|
|
139 | (50) |
|
|
|
139 | (8) |
|
What Is the Async_Io_Completion Wait Type? |
|
|
140 | (1) |
|
Async_Io_Completion Example |
|
|
141 | (1) |
|
Lowering Async_Io_Completion Waits |
|
|
142 | (5) |
|
Async_Io_Completion Summary |
|
|
147 | (1) |
|
|
|
147 | (4) |
|
What Is the Async_Network_Io Wait Type? |
|
|
147 | (1) |
|
|
|
148 | (1) |
|
Lowering Async_Network_Io Waits |
|
|
149 | (2) |
|
|
|
151 | (1) |
|
|
|
151 | (3) |
|
What Is the Cmemthread Wait Type? |
|
|
151 | (2) |
|
Lowering Cmemthread Waits |
|
|
153 | (1) |
|
|
|
154 | (1) |
|
|
|
154 | (3) |
|
What Is the Io_Completion Wait Type? |
|
|
155 | (1) |
|
|
|
155 | (2) |
|
Lowering Io_Completion Waits |
|
|
157 | (1) |
|
|
|
157 | (1) |
|
|
|
157 | (6) |
|
What Are the Logbuffer and Writelog Wait Types? |
|
|
158 | (2) |
|
Logbuffer and Writelog Example |
|
|
160 | (2) |
|
Lowering Logbuffer and Writelog Waits |
|
|
162 | (1) |
|
Logbuffer and Writelog Summary |
|
|
163 | (1) |
|
|
|
163 | (8) |
|
What Is the Resource_Semaphore Wait Type? |
|
|
163 | (2) |
|
Resource_Semaphore Example |
|
|
165 | (5) |
|
Lowering Resource_Semaphore Waits |
|
|
170 | (1) |
|
Resource_Semaphore Summary |
|
|
171 | (1) |
|
Resource_Semaphore_Query_Compile |
|
|
171 | (8) |
|
What Is the Resource_Semaphore_Query_Compile Wait Type? |
|
|
172 | (2) |
|
Resource_Semaphore_Query_Compile Example |
|
|
174 | (3) |
|
Lowering Resource_Semaphore_Query_Compile Waits |
|
|
177 | (1) |
|
Resource_Semaphore_Query_Compile Summary |
|
|
178 | (1) |
|
|
|
179 | (7) |
|
What Is the Sleep_Bpool_Flush Wait Type? |
|
|
179 | (3) |
|
Sleep_Bpool_Flush Example |
|
|
182 | (3) |
|
Lowering Sleep_Bpool_Flush Waits |
|
|
185 | (1) |
|
Sleep_Bpool_Flush Summary |
|
|
185 | (1) |
|
|
|
186 | (3) |
|
What Is the Write_Completion Wait Type? |
|
|
186 | (1) |
|
|
|
186 | (1) |
|
Lowering Write_Completion Waits |
|
|
187 | (1) |
|
|
|
187 | (2) |
|
Chapter 7 Backup-Related Wait Types |
|
|
189 | (14) |
|
|
|
190 | (5) |
|
What Is the Backupbuffer Wait Type? |
|
|
190 | (3) |
|
|
|
193 | (1) |
|
Lowering Backupbuffer Waits |
|
|
194 | (1) |
|
|
|
195 | (1) |
|
|
|
195 | (3) |
|
What Is the Backupio Wait Type? |
|
|
196 | (1) |
|
|
|
196 | (1) |
|
|
|
197 | (1) |
|
|
|
198 | (1) |
|
|
|
198 | (5) |
|
What Is the Backupthread Wait Type? |
|
|
198 | (1) |
|
|
|
199 | (1) |
|
Lowering Backupthread Waits |
|
|
200 | (1) |
|
|
|
201 | (2) |
|
Chapter 8 Lock-Related Wait Types |
|
|
203 | (32) |
|
Introduction to Locking and Blocking |
|
|
205 | (1) |
|
Lock Modes and Compatibility |
|
|
205 | (2) |
|
|
|
207 | (1) |
|
|
|
208 | (4) |
|
Querying Lock Information |
|
|
212 | (4) |
|
|
|
216 | (4) |
|
What Is the LCK_M_S Wait Type? |
|
|
216 | (1) |
|
|
|
217 | (1) |
|
|
|
218 | (1) |
|
|
|
219 | (1) |
|
|
|
220 | (3) |
|
What Is the LCK_M_U Wait Type? |
|
|
220 | (2) |
|
|
|
222 | (1) |
|
|
|
223 | (1) |
|
|
|
223 | (1) |
|
|
|
223 | (3) |
|
What Is the LCK_M_X Wait Type? |
|
|
224 | (1) |
|
|
|
224 | (1) |
|
|
|
225 | (1) |
|
|
|
226 | (1) |
|
|
|
226 | (4) |
|
What Is the LCK_M_I[ xx] Wait Type? |
|
|
226 | (1) |
|
|
|
227 | (2) |
|
Lowering LCK_M_I[ xx] Waits |
|
|
229 | (1) |
|
|
|
229 | (1) |
|
LCK_M_SCH_S and LCK_M_SCH_M |
|
|
230 | (5) |
|
What Are the LCK_M_SCH_S and LCK_M_SCH_M Wait Types? |
|
|
230 | (1) |
|
LCK_M_SCH_S and LCK_M_SCH_M Example |
|
|
231 | (2) |
|
Lowering LCK_M_SCH_S and LCK_M_SCH_M Waits |
|
|
233 | (1) |
|
LCK_M_SCH_S and LCK_M_SCH_M Summary |
|
|
233 | (2) |
|
Chapter 9 Latch-Related Wait Types |
|
|
235 | (44) |
|
|
|
235 | (12) |
|
|
|
237 | (1) |
|
|
|
238 | (2) |
|
|
|
240 | (1) |
|
|
|
241 | (6) |
|
|
|
247 | (11) |
|
What Is the Pagelatch_[ xx] Wait Type? |
|
|
247 | (1) |
|
|
|
248 | (4) |
|
Lowering Pagelatch_[ xx] Waits |
|
|
252 | (6) |
|
|
|
258 | (1) |
|
|
|
258 | (8) |
|
What Is the LATCH_[ xx] Wait Type? |
|
|
259 | (1) |
|
|
|
259 | (6) |
|
Lowering LATCH_[ xx] Waits |
|
|
265 | (1) |
|
|
|
266 | (1) |
|
|
|
266 | (13) |
|
What Is the Pageiolatch_[ xx] Wait Type? |
|
|
267 | (2) |
|
Pageiolatch_[ xx] Example |
|
|
269 | (1) |
|
Lowering Pageiolatch_[ xx] Waits |
|
|
270 | (7) |
|
Pageiolatch_[ xx] Summary |
|
|
277 | (2) |
|
Chapter 10 High-Availability and Disaster-Recovery Wait Types |
|
|
279 | (22) |
|
|
|
280 | (7) |
|
What Is the Dbmirror_Send Wait Type? |
|
|
283 | (1) |
|
|
|
283 | (2) |
|
Lowering Dbmirror_Send Waits |
|
|
285 | (1) |
|
|
|
286 | (1) |
|
Hadr_Logcapture_Wait and Hadr_Work_Queue |
|
|
287 | (3) |
|
What Are the Hadr_Logcapture_Wait and Hadr_Work_Queue Wait Types? |
|
|
287 | (3) |
|
Hadr_Logcapture_Wait and Hadr_Work_Queue Summary |
|
|
290 | (1) |
|
|
|
290 | (7) |
|
What Is the Hadr_Sync_Commit Wait Type? |
|
|
290 | (1) |
|
|
|
291 | (3) |
|
Lowering Hadr_Sync_Commit Waits |
|
|
294 | (3) |
|
|
|
297 | (1) |
|
|
|
297 | (4) |
|
What Is the Redo_Thread_Pending_Work Wait Type? |
|
|
298 | (2) |
|
Redo_Thread_Pending_Work Summary |
|
|
300 | (1) |
|
Chapter 11 Preemptive Wait Types |
|
|
301 | (26) |
|
|
|
302 | (3) |
|
Preemptive_Os_Encryptmessage and Preemptive_Os_Decryptmessage |
|
|
305 | (8) |
|
What Are the Preemptive_Os_Encryptmessage and Preemptive_Os_Decryptmessage Wait Types? |
|
|
305 | (1) |
|
Preemptive_Os_Encryptmessage and Preemptive_Os_Decryptmessage Example |
|
|
306 | (6) |
|
Lowering Preemptive_Os_Encryptmessage and Preemptive_Os_Decryptmessage Waits |
|
|
312 | (1) |
|
Preemptive_Os_Encryptmessage and Preemptive_Os_Decryptmessage Summary |
|
|
313 | (1) |
|
Preemptive_Os_Writefilegather |
|
|
313 | (3) |
|
What Is the Preemptive_Os_Writefilegather Wait Type? |
|
|
313 | (1) |
|
Preemptive_Os_Writefilegather Example |
|
|
314 | (1) |
|
Lowering Preemptive_Os_Writefilegather Waits |
|
|
315 | (1) |
|
Preemptive_Os_Writefilegather Summary |
|
|
316 | (1) |
|
Preemptive_Os_Authenticationops |
|
|
316 | (5) |
|
What Is the Preemptive_Os_Authenticationops Wait Type? |
|
|
317 | (1) |
|
Preemptive_Os_Authenticationops Example |
|
|
318 | (1) |
|
Lowering Preemptive_Os_Authenticationops Waits |
|
|
319 | (2) |
|
Preemptive_Os_Authenticationops Summary |
|
|
321 | (1) |
|
Preemptive_Os_Getprocaddress |
|
|
321 | (6) |
|
What Is the Preemptive_Os_Getprocaddress Wait Type? |
|
|
322 | (2) |
|
Preemptive_Os_Getprocaddress Example |
|
|
324 | (1) |
|
Lowering Preemptive_Os_Getprocaddress Waits |
|
|
325 | (1) |
|
Preemptive_Os_Getprocaddress Summary |
|
|
325 | (2) |
|
Chapter 12 Background and Miscellaneous Wait Types |
|
|
327 | (28) |
|
|
|
328 | (4) |
|
What Is the Checkpoint_Queue Wait Type? |
|
|
328 | (3) |
|
|
|
331 | (1) |
|
|
|
332 | (3) |
|
What Is the Dirty_Page_Poll Wait Type? |
|
|
332 | (3) |
|
|
|
335 | (1) |
|
|
|
335 | (2) |
|
What Is the Lazywriter_Sleep Wait Type? |
|
|
335 | (2) |
|
|
|
337 | (1) |
|
|
|
337 | (3) |
|
What Is the MSQL_XP Wait Type? |
|
|
337 | (1) |
|
|
|
338 | (1) |
|
|
|
339 | (1) |
|
|
|
340 | (1) |
|
|
|
340 | (2) |
|
What Is the OLEDB Wait Type? |
|
|
340 | (1) |
|
|
|
340 | (1) |
|
|
|
341 | (1) |
|
|
|
342 | (1) |
|
|
|
342 | (9) |
|
What Is the Tracewrite Wait Type? |
|
|
343 | (1) |
|
|
|
343 | (5) |
|
Lowering Tracewrite Waits |
|
|
348 | (3) |
|
|
|
351 | (1) |
|
|
|
351 | (4) |
|
What Is the Waitfor Wait Type? |
|
|
352 | (1) |
|
|
|
352 | (1) |
|
|
|
353 | (2) |
|
Chapter 13 In-Memory OLTP-Related Wait Types |
|
|
355 | (18) |
|
Introduction to In-Memory OLTP |
|
|
355 | (6) |
|
|
|
356 | (4) |
|
|
|
360 | (1) |
|
|
|
360 | (1) |
|
|
|
361 | (6) |
|
What Is the WAIT_XTP_HOST_WAIT Wait Type? |
|
|
361 | (5) |
|
WAIT_XTP_HOST_WAIT Summary |
|
|
366 | (1) |
|
|
|
367 | (3) |
|
What Is the WAIT_XTP_CKPT_CLOSE Wait Type? |
|
|
367 | (3) |
|
WAIT_XTP_CKPT_CLOSE Summary |
|
|
370 | (1) |
|
WAIT_XTP_OFFLINE_CKPT_NEW_LOG |
|
|
370 | (3) |
|
What Is the WAIT_XTP_OFFLINE_CKPT_NEW_LOG Wait Type? |
|
|
370 | (2) |
|
WAIT_XTP_OFFLINE_CKPT_NEW_LOG Summary |
|
|
372 | (1) |
|
Appendix I Example SQL Server Machine Configurations |
|
|
373 | (4) |
|
|
|
373 | (1) |
|
|
|
374 | (3) |
|
|
|
377 | (4) |
|
Appendix III Latch Classes |
|
|
381 | (10) |
| Index |
|
391 | |