Статистика ожиданий или как найти место "где болит" Sergey Syrovatchenko
About me Sergey Syrovatchenko SQL Server DBA Хабр: @AlanDenton Mail: sergey.syrovatchenko@gmail.com
Troubleshooting Wait Stats Error Log Execution Plan Performance Monitor XEvents DMV SQL Profiler
Wait Stats When SQL Server executes a request but the resources aren’t available to complete the request a wait occurs. All waits is logged. Waits will show you all performance bottlenecks in your SQL Server instance.
Thread Scheduling SQL Server uses his own schedulers to manage CPU time for threads. Thread scheduling performed by the SQLOS layer of Storage Engine. Each logical processor core has a scheduler.
Scheduler SCHEDULER Signal Wait Time Resource Wait Time RUNNING SPID 56 SCHEDULER Signal Wait Time Resource Wait Time SPID 58 SPID 67 SPID 57 SPID 72 RUNNABLE SUSPENDED Runnable Queue Waiter List CPU Time + Signal Wait Time + Resource Wait Time Wait Time Total Execution Time
How SQL Server executes a query? Thread Pool <= 4 CPU = 512 > 4 CPU = 512 + ((CPU – 4) * 16) Worker Worker Worker Task Execution Parsing Binding Optimization Query Execution Tasks Queue Task Task Cache Task DB 01010100 Plan Cache Buffer Pool SELECT…
Most Common Waits CPU/Parallelism: SOS_SCHEDULER_YIELD, CXPACKET, THREADPOOL Memory: RESOURCE_SEMAPHORE, PAGELATCH_*, RESOURCE_SEMAPHORE_QUERY_COMPILE Disk: WRITELOG, PAGEIOLATCH_*, IO_COMPLETION, WRITE_COMPLETION, ASYNC_IO_COMPLETION, BAD_PAGE_PROCESS Locking: LCK_* Network: ASYNC_NETWORK_IO Backup: BACKUPIO, BACKUPBUFFER Other: TRACEWRITE, OLEDB
CXPACKET Gather Streams Stream Aggregate Repartition Streams Hash Match Aggregate Distribute Streams T1 CXPACKET T1 CXPACKET T2 CXPACKET T2 CXPACKET T3 T3
PAGEIOLATCH Buffer Pool Access Methods Buffer Manager Database Files 8K SELECT 64K Database Files
PAGELATCH Buffer Pool 2 1 tempdb ndf file PFS GAM tempdb mdf file PFS X 1 tempdb mdf file PFS GAM CREATE TABLE # tempdb mdf file CREATE TABLE # tempdb ndf file PFS GAM CREATE TABLE # CREATE TABLE # CREATE TABLE # CREATE TABLE # PFS GAM CREATE TABLE # CREATE TABLE #
WRITELOG Buffer Pool Access Methods Buffer Manager Log Manager INSERT UPDATE DELETE 4 1 Buffer Pool Access Methods 2 Buffer Manager 3 8K 11 5 9 10 4 Lazy writer Checkpoint 64K Log Manager async 8 6 Database Files Transaction Log sync Log Buffer 7 60K buffer full tran commit sys.sp_flush_log
BACKUPIO + BACKUPBUFFER Read Thread Write Thread Buffer Buffer Buffer Buffer DB BAK Buffer Buffer Buffer Buffer ASYNC_IO_COMPLETION BACKUPIO ASYNC_IO_COMPLETION ASYNC_NETWORK_IO Buffer Buffer BACKUPBUFFER
Thank You! sergey.syrovatchenko@gmail.com