SlideShare a Scribd company logo
Analyzing SQL Server wait
stats
Discover why SQL Server is
waiting
Get in touch
http://www.sqlmaster.de
uwe.ricken@db-berater.de
@dbberater
Uwe Ricken
#SQLintheCityUS
The Microsoft Certified Solutions Master (MCSM) and Microsoft Certified Master
(MCM) programs recognize the most experienced IT professionals who demonstrate
and validate their deep technical skills to successfully design and implement technical
solutions in a complex business environment.
Microsoft Certified Solutions Expert (MCSE) certifications are designed to recognize IT
professionals who can design and build solutions across multiple technologies, both on-
premises and in the cloud.
The Microsoft Most Valuable Professional (MVP) Award is our way of saying thank you
to exceptional, independent community leaders who share their passion, technical
expertise, and real-world knowledge of Microsoft products with others.
Uwe Ricken
db Berater GmbH
AGENDA
• what is a WAIT?
• what is a QUEUE?
• when SQL Server waits
• common Wait Stats and reasons
When SQL Server waits
depiction: http://rusanu.com/2013/08/01/understanding-how-sql-server-executes-a-query/
What is a „Wait“?
• A „wait“ occurs when a thread needs a
resource or runs out of time
– A lock on a page prevents further access
– A data page must be read from the disk
– Results from a parallel query
– …
• A waiting thread runs into a “queue”
What is a „Queue“?
• A „queue“ holds one or more waiting threads
• The “suspended” queue holds threads which
are waiting for resources
• The “runnable” queue holds threads which are
waiting for CPU time
• SQL Server provides DMV’s for the monitoring
of the status
When SQL Server waits
• sys.dm_os_wait_stats
– Information about waits which have been
executed!
• sys.dm_os_waiting_tasks
– Information about threads which are currently
waiting for resources.
When SQL Server waits
running
suspendedrunnable
60: RUNNING
54: WAITFOR
56: ASYNC_...
68: LCK_M_S
70: PAGELA..
55: RUNNABLE
59: RUNNABLE
72: RUNNABLE
51: RUNNABLE
When SQL Server waits
running
suspendedrunnable
55: RUNNING
>4ms
54: WAITFOR
56: ASYNC_...
70: PAGELA..
59: RUNNABLE
72: RUNNABLE
51: RUNNABLE
68: RUNNABLE
When SQL Server waits
running
suspendedrunnable
59: RUNNING
54: WAITFOR
56: ASYNC_...
70: PAGELA..
72: RUNNABLE
51: RUNNABLE
68: RUNNABLE
55: RUNNABLE
Quantum: 4ms
SOS_SCHEDULER_YIELD
Most common wait types
• CXPACKET
• ASYNC_NETWORK_IO
• ASYNC_IO_COMPLETION
• PAGELATCH_XX
• PAGEIOLATCH_XX
• SOS_SCHEDULER_YIELD
• WRITELOG
• THREADPOOL
CXPACKET
• occurs when a parallel query is executing
– Examine the long-running parallel query and
tune it if necessary.
– To ensure “efficient” parallelism, check that the
statistics on tables and indexes used by the
query are up to date.
CXPACKET
Transaction
1.000 records
1.000 records
1.000 records
1.000 records
CONTROLLER THREAD
Demo
#SQLintheCityUS
ASYNC_NETWORK_IO
• Your application code may not be
retrieving data correctly!
• There are very large data sets being
requested by the client!
• An application is requesting large amounts
of data!
Demo
#SQLintheCityUS
ASYNC_IO_COMPLETION
• This occurs when SQL Server is waiting for
asynchronous I/O operations to finish
• Look for additional waits in the top ranking
– IO_COMPLETION
– LOGMGR
– WRITELOG
– PAGEIOLATCH_*
Demo
#SQLintheCityUS
PAGEIOLATCH_??
• Buffer Latch for a page object on the disk
– DT (destroy)
– EX (exclusive)
– KP (keep)
– SH (shared)
– UP (update)
Demo
#SQLintheCityUS
PAGELATCH_??
• PAGELATCH_* latches are lightweight,
non-configurable internal locks used by
SQL Server’s storage engine to protect
concurrent access to pages in the
BUFFER POOL
Demo
#SQLintheCityUS
SOS_SCHEDULER_YIELD
• This common wait isn’t necessarily a
problem
• It indicates that SQL Server CPU
scheduling is working efficiently.
– RUNNING | SUSPENDED | RUNNABLE
Demo
#SQLintheCityUS
WRITELOG
• This wait occurs when data in the log cache is
being flushed to disk.
• Whenever a data page is updated, it’s written
to the buffer cache and the log cache.
• Data in the log cache is then written to the
transaction log file on the physical disk once
the transaction is complete.
Demo
#SQLintheCityUS
THREADPOOL
• SQL Server assigns a scheduler to each CPU
core to manage internal threads.
• Some of these threads are worker threads that are
assigned to query requests on a one-to-one basis.
• If every worker thread is busy, additional requests
can't be assigned straight away.
• SQL Server attempts to manage requests more
efficiently by creating a pool of worker threads, so
the next available worker thread from the pool will
pick up the task.
• If every worker thread remains busy, SQL Server
can't accept new requests and will hang.
Cores 32 bit 64 bit
<=4 256 512
5 – 8 288 576
9 – 16 352 704
32 480 960
Demo
#SQLintheCityUS
Want to try the tools you’ve just seen?
Head to the Hands-on Labs
#SQLintheCityUS

More Related Content

PPT
Sql Server Performance Tuning
PDF
AWS Glue - let's get stuck in!
PDF
InnoDB Flushing and Checkpoints
PPTX
SQL Server Wait Types Everyone Should Know
PDF
Introduction to Presto at Treasure Data
PDF
Wait! What’s going on inside my database?
PDF
Performance tuning in sql server
PDF
SQL Server Performance Tuning Baseline
Sql Server Performance Tuning
AWS Glue - let's get stuck in!
InnoDB Flushing and Checkpoints
SQL Server Wait Types Everyone Should Know
Introduction to Presto at Treasure Data
Wait! What’s going on inside my database?
Performance tuning in sql server
SQL Server Performance Tuning Baseline

What's hot (20)

PPTX
Admission Control in Impala
PPTX
Hive Bucketing in Apache Spark
PPT
Query processing-and-optimization
PPTX
Stop the Chaos! Get Real Oracle Performance by Query Tuning Part 1
PDF
PPTX
Performance Optimizations in Apache Impala
PDF
The Basic Configuration of a Microcomputer
PDF
Introduction to MariaDB
PPTX
Processing Large Data with Apache Spark -- HasGeek
PPTX
What is NoSQL and CAP Theorem
PDF
Enduring Impact in Data-Driven Science
PPTX
End-to-end Troubleshooting Checklist for Microsoft SQL Server
PDF
Database & Database Users
PPTX
Join semantics in kafka streams
PPTX
Sql vs NoSQL-Presentation
PDF
Deep Dive into the New Features of Apache Spark 3.1
PDF
Experiences Migrating Hive Workload to SparkSQL with Jie Xiong and Zhan Zhang
ODP
Presto
PPTX
[135] 오픈소스 데이터베이스, 은행 서비스에 첫발을 내밀다.
PPTX
Understanding Query Optimization with ‘regular’ and ‘Exadata’ Oracle
Admission Control in Impala
Hive Bucketing in Apache Spark
Query processing-and-optimization
Stop the Chaos! Get Real Oracle Performance by Query Tuning Part 1
Performance Optimizations in Apache Impala
The Basic Configuration of a Microcomputer
Introduction to MariaDB
Processing Large Data with Apache Spark -- HasGeek
What is NoSQL and CAP Theorem
Enduring Impact in Data-Driven Science
End-to-end Troubleshooting Checklist for Microsoft SQL Server
Database & Database Users
Join semantics in kafka streams
Sql vs NoSQL-Presentation
Deep Dive into the New Features of Apache Spark 3.1
Experiences Migrating Hive Workload to SparkSQL with Jie Xiong and Zhan Zhang
Presto
[135] 오픈소스 데이터베이스, 은행 서비스에 첫발을 내밀다.
Understanding Query Optimization with ‘regular’ and ‘Exadata’ Oracle
Ad

Viewers also liked (7)

PPTX
SQL Server Performance Counters 101
PPTX
SQL Server Transaction Log Deep Dive Session - PASS Hamburg
PDF
SQL Server ASYNC_NETWORK_IO Wait Type Explained
PPTX
Sql Automation 20090610
PDF
Green plum培训材料
PPTX
Foro Universidades 2014. Pensando en la nube - SharePoint como Web Corporativa
PPTX
Declaración anual México 2016
SQL Server Performance Counters 101
SQL Server Transaction Log Deep Dive Session - PASS Hamburg
SQL Server ASYNC_NETWORK_IO Wait Type Explained
Sql Automation 20090610
Green plum培训材料
Foro Universidades 2014. Pensando en la nube - SharePoint como Web Corporativa
Declaración anual México 2016
Ad

Similar to Analyzing SQL Server wait stats, hands-on! (20)

PPTX
Wait Watchers ; Gain SQL Performance Increases Fast!
PPTX
Configuring Sage 500 for Performance
PDF
Oracle Database Performance Tuning Advanced Features and Best Practices for DBAs
PDF
Breaking data
PPTX
SQL 2014 In-Memory OLTP
PDF
Collaborate 2019 - How to Understand an AWR Report
PPTX
[JSS2015] AlwaysOn 2016
PPTX
24 Hours of PASS, Summit Preview Session: Virtual SQL Server CPUs
PPT
Collaborate 2011-tuning-ebusiness-416502
PDF
collab2011-tuning-ebusiness-421966.pdf
PDF
SQL Server Tuning to Improve Database Performance
PPTX
SQL Server 2016: Just a Few of Our DBA's Favorite Things
PDF
Modernizing your database with SQL Server 2019
PDF
Oracle MySQL Tutorial -- MySQL NoSQL Cloud Buenos Aires Nov, 13 2014
PDF
Always on in sql server 2017
PDF
Alwayson in sqlserver2017
PDF
Making MySQL Administration a Breeze - A Look Into a MySQL DBA's Toolchest
PPTX
SQL Explore 2012: P&T Part 1
PPTX
Copy Data Management for the DBA
PPTX
WebLogic Stability; Detect and Analyse Stuck Threads
Wait Watchers ; Gain SQL Performance Increases Fast!
Configuring Sage 500 for Performance
Oracle Database Performance Tuning Advanced Features and Best Practices for DBAs
Breaking data
SQL 2014 In-Memory OLTP
Collaborate 2019 - How to Understand an AWR Report
[JSS2015] AlwaysOn 2016
24 Hours of PASS, Summit Preview Session: Virtual SQL Server CPUs
Collaborate 2011-tuning-ebusiness-416502
collab2011-tuning-ebusiness-421966.pdf
SQL Server Tuning to Improve Database Performance
SQL Server 2016: Just a Few of Our DBA's Favorite Things
Modernizing your database with SQL Server 2019
Oracle MySQL Tutorial -- MySQL NoSQL Cloud Buenos Aires Nov, 13 2014
Always on in sql server 2017
Alwayson in sqlserver2017
Making MySQL Administration a Breeze - A Look Into a MySQL DBA's Toolchest
SQL Explore 2012: P&T Part 1
Copy Data Management for the DBA
WebLogic Stability; Detect and Analyse Stuck Threads

More from Red Gate Software (20)

PDF
The future of DevOps: fully left-shifted deployments with version control and...
PDF
Embracing DevOps through database migrations with Flyway
PPTX
Database DevOps for Managed Service Providers
PDF
Mizuho Financial: Launching our Database DevOps journey
PDF
7 steps to effective SQL Server monitoring
PDF
Level up your deployments for SQL Source Control
PDF
Key findings from the 2020 state of database dev ops report
PPTX
Extend DevOps to Your SQL Server Databases
PDF
2019 year in review slides
PPTX
What we learned at PASS Summit in 2019
PPTX
Quality in Software Development: Anglia Ruskin University
PPTX
How SQL Change Automation helps you deliver value faster
PPTX
DevOps essentials from Abel Wang and Steve Jones
PPTX
Successfully migrating existing databases to Azure
PPTX
The Ultimate Guide to Choosing and Implementing the Right Monitoring Tool
PDF
Everything You Need to Know About the 2019 DORA Accelerate State of DevOps Re...
PDF
Using Redgate, AKS and Azure to bring DevOps to your database
PDF
Using Redgate, AKS and Azure to bring DevOps to your Database
PDF
How to Pitch a Software Development Initiative and Ignite Culture Change
PDF
Taming the Wild West
The future of DevOps: fully left-shifted deployments with version control and...
Embracing DevOps through database migrations with Flyway
Database DevOps for Managed Service Providers
Mizuho Financial: Launching our Database DevOps journey
7 steps to effective SQL Server monitoring
Level up your deployments for SQL Source Control
Key findings from the 2020 state of database dev ops report
Extend DevOps to Your SQL Server Databases
2019 year in review slides
What we learned at PASS Summit in 2019
Quality in Software Development: Anglia Ruskin University
How SQL Change Automation helps you deliver value faster
DevOps essentials from Abel Wang and Steve Jones
Successfully migrating existing databases to Azure
The Ultimate Guide to Choosing and Implementing the Right Monitoring Tool
Everything You Need to Know About the 2019 DORA Accelerate State of DevOps Re...
Using Redgate, AKS and Azure to bring DevOps to your database
Using Redgate, AKS and Azure to bring DevOps to your Database
How to Pitch a Software Development Initiative and Ignite Culture Change
Taming the Wild West

Recently uploaded (20)

PDF
How to Migrate SBCGlobal Email to Yahoo Easily
PDF
How Creative Agencies Leverage Project Management Software.pdf
PPTX
history of c programming in notes for students .pptx
PDF
Flood Susceptibility Mapping Using Image-Based 2D-CNN Deep Learnin. Overview ...
PPTX
Introduction to Artificial Intelligence
PDF
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
PDF
wealthsignaloriginal-com-DS-text-... (1).pdf
PDF
Understanding Forklifts - TECH EHS Solution
PPTX
Odoo POS Development Services by CandidRoot Solutions
PDF
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
PDF
PTS Company Brochure 2025 (1).pdf.......
PDF
top salesforce developer skills in 2025.pdf
PDF
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
PDF
2025 Textile ERP Trends: SAP, Odoo & Oracle
PDF
Which alternative to Crystal Reports is best for small or large businesses.pdf
PDF
medical staffing services at VALiNTRY
PDF
Softaken Excel to vCard Converter Software.pdf
PDF
Adobe Illustrator 28.6 Crack My Vision of Vector Design
PPTX
ai tools demonstartion for schools and inter college
How to Migrate SBCGlobal Email to Yahoo Easily
How Creative Agencies Leverage Project Management Software.pdf
history of c programming in notes for students .pptx
Flood Susceptibility Mapping Using Image-Based 2D-CNN Deep Learnin. Overview ...
Introduction to Artificial Intelligence
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
wealthsignaloriginal-com-DS-text-... (1).pdf
Understanding Forklifts - TECH EHS Solution
Odoo POS Development Services by CandidRoot Solutions
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
PTS Company Brochure 2025 (1).pdf.......
top salesforce developer skills in 2025.pdf
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
2025 Textile ERP Trends: SAP, Odoo & Oracle
Which alternative to Crystal Reports is best for small or large businesses.pdf
medical staffing services at VALiNTRY
Softaken Excel to vCard Converter Software.pdf
Adobe Illustrator 28.6 Crack My Vision of Vector Design
ai tools demonstartion for schools and inter college

Analyzing SQL Server wait stats, hands-on!

  • 1. Analyzing SQL Server wait stats Discover why SQL Server is waiting
  • 3. The Microsoft Certified Solutions Master (MCSM) and Microsoft Certified Master (MCM) programs recognize the most experienced IT professionals who demonstrate and validate their deep technical skills to successfully design and implement technical solutions in a complex business environment. Microsoft Certified Solutions Expert (MCSE) certifications are designed to recognize IT professionals who can design and build solutions across multiple technologies, both on- premises and in the cloud. The Microsoft Most Valuable Professional (MVP) Award is our way of saying thank you to exceptional, independent community leaders who share their passion, technical expertise, and real-world knowledge of Microsoft products with others. Uwe Ricken db Berater GmbH
  • 4. AGENDA • what is a WAIT? • what is a QUEUE? • when SQL Server waits • common Wait Stats and reasons
  • 5. When SQL Server waits depiction: http://rusanu.com/2013/08/01/understanding-how-sql-server-executes-a-query/
  • 6. What is a „Wait“? • A „wait“ occurs when a thread needs a resource or runs out of time – A lock on a page prevents further access – A data page must be read from the disk – Results from a parallel query – … • A waiting thread runs into a “queue”
  • 7. What is a „Queue“? • A „queue“ holds one or more waiting threads • The “suspended” queue holds threads which are waiting for resources • The “runnable” queue holds threads which are waiting for CPU time • SQL Server provides DMV’s for the monitoring of the status
  • 8. When SQL Server waits • sys.dm_os_wait_stats – Information about waits which have been executed! • sys.dm_os_waiting_tasks – Information about threads which are currently waiting for resources.
  • 9. When SQL Server waits running suspendedrunnable 60: RUNNING 54: WAITFOR 56: ASYNC_... 68: LCK_M_S 70: PAGELA.. 55: RUNNABLE 59: RUNNABLE 72: RUNNABLE 51: RUNNABLE
  • 10. When SQL Server waits running suspendedrunnable 55: RUNNING >4ms 54: WAITFOR 56: ASYNC_... 70: PAGELA.. 59: RUNNABLE 72: RUNNABLE 51: RUNNABLE 68: RUNNABLE
  • 11. When SQL Server waits running suspendedrunnable 59: RUNNING 54: WAITFOR 56: ASYNC_... 70: PAGELA.. 72: RUNNABLE 51: RUNNABLE 68: RUNNABLE 55: RUNNABLE Quantum: 4ms SOS_SCHEDULER_YIELD
  • 12. Most common wait types • CXPACKET • ASYNC_NETWORK_IO • ASYNC_IO_COMPLETION • PAGELATCH_XX • PAGEIOLATCH_XX • SOS_SCHEDULER_YIELD • WRITELOG • THREADPOOL
  • 13. CXPACKET • occurs when a parallel query is executing – Examine the long-running parallel query and tune it if necessary. – To ensure “efficient” parallelism, check that the statistics on tables and indexes used by the query are up to date.
  • 14. CXPACKET Transaction 1.000 records 1.000 records 1.000 records 1.000 records CONTROLLER THREAD
  • 16. ASYNC_NETWORK_IO • Your application code may not be retrieving data correctly! • There are very large data sets being requested by the client! • An application is requesting large amounts of data!
  • 18. ASYNC_IO_COMPLETION • This occurs when SQL Server is waiting for asynchronous I/O operations to finish • Look for additional waits in the top ranking – IO_COMPLETION – LOGMGR – WRITELOG – PAGEIOLATCH_*
  • 20. PAGEIOLATCH_?? • Buffer Latch for a page object on the disk – DT (destroy) – EX (exclusive) – KP (keep) – SH (shared) – UP (update)
  • 22. PAGELATCH_?? • PAGELATCH_* latches are lightweight, non-configurable internal locks used by SQL Server’s storage engine to protect concurrent access to pages in the BUFFER POOL
  • 24. SOS_SCHEDULER_YIELD • This common wait isn’t necessarily a problem • It indicates that SQL Server CPU scheduling is working efficiently. – RUNNING | SUSPENDED | RUNNABLE
  • 26. WRITELOG • This wait occurs when data in the log cache is being flushed to disk. • Whenever a data page is updated, it’s written to the buffer cache and the log cache. • Data in the log cache is then written to the transaction log file on the physical disk once the transaction is complete.
  • 28. THREADPOOL • SQL Server assigns a scheduler to each CPU core to manage internal threads. • Some of these threads are worker threads that are assigned to query requests on a one-to-one basis. • If every worker thread is busy, additional requests can't be assigned straight away. • SQL Server attempts to manage requests more efficiently by creating a pool of worker threads, so the next available worker thread from the pool will pick up the task. • If every worker thread remains busy, SQL Server can't accept new requests and will hang. Cores 32 bit 64 bit <=4 256 512 5 – 8 288 576 9 – 16 352 704 32 480 960
  • 30. Want to try the tools you’ve just seen? Head to the Hands-on Labs #SQLintheCityUS