Professional Documents
Culture Documents
Boost SQL Server Performance With Wait Statistics
Boost SQL Server Performance With Wait Statistics
Boost SQL Server Performance With Wait Statistics
Newsletter
Boost SQL Server Performance with Wait Statistics
October 26, 2020 by Esat Erkec
Follow us!
In this article, we will explore, how we can increase SQL Server performance with the help of the wait statistics.
Wait statistics are one of the most important indicators to identify performance issues in SQL Server. When we
want to troubleshoot any performance issue, at first we need to diagnose the problem correctly because correctly
diagnosing problems help with half of the solution. Now, let’s learn wait statistics which helps to identify
performance issues properly.
Popular
Running status indicates that the scheduled thread is currently being processed by the CPU
Different ways to SQL delete duplicate rows from a
Suspended status indicates that the assigned thread is waiting for a resource to be available. Such as, if any SQL Table
thread wants to access a data page that acquires an exclusive lock, it waits in the suspended status until the SQL Convert Date functions and formats
exclusive lock is removed and then it can access the page
SQL PARTITION BY Clause overview
Runnable status indicates that the thread is not waiting for any resources, but the CPU still unable to
How to UPDATE from a SELECT statement in SQL
process this task because it is dealing with another task Server
The sys.dm_os_wait_stats dynamic management view can be used to obtain information about the wait type SQL Server functions for converting a String to a
Date
details. This view holds cumulative statistics about the wait types until the database engine restarted or the wait
What is the difference between Clustered and Non‐
statistics cleared. When we query the sys.dm_os_wait_stats, the following columns will return:
Clustered Indexes in SQL Server?
The following query will return the top 10 wait types and sorts them in ascending order by waiting time.
Tip: We can ignore some wait types because these wait types are related to the internal management of
SQL Server so we don’t need to consider these wait types
they are so many. For this reason, we can search the particular wait types on the web or use the following wait All about locking in SQL Server
type’s dictionaries that give comprehensive information: SQL Server stored procedures for beginners
However, some wait types might occur very commonly in the SQL Server instances, therefore, it will be beneficial Solutions
to know the common wait types.
Read a SQL Server transaction log
As we mentioned, SQLOS accomplishes the CPU management for SQL Server. SQLOS allows the thread to be How to quickly search for SQL database data and
objects
processed by the CPU at a quantum time. If the processing of the thread is not completed and all the resources
Synchronize SQL Server databases in different
are available state for this thread, SQLOS moves the thread to the runnable queue and it begins to wait for remote sources
reprocessing. SOS_SCHEDULER_YIELD wait type is captured and recorded when the thread is waiting in the
Recover SQL data from a dropped table without
runnable queue. This wait type shows a CPU pressure but it should be evaluated with two other indicators. The backups
first one is the sys.dm_os_tasks view, this dynamic management view gives compressive information about the How to restore specific table﴾s﴿ from a SQL Server
active tasks in the SQL Server. With the help of this view, we can monitor how many threads wait in the runnable database backup
status and if this value reaches the big numbers during the day, we have to suspect a CPU pressure. Recover deleted SQL data from transaction logs
Another indicator that we can use with SOS_SCHEDULER_YIELD is the signal_wait_time_ms column of the Open LDF file and view LDF file content
sys.dm_os_wait_stats view. As we stated, this value indicates the time which spends in the runnable queue for a Quickly convert SQL code to language‐specific client
code
thread. As a result, if we monitor the following metrics, we need to suspect about CPU pressure:
How to recover a single table from a SQL Server
database backup
If the SOS_SCHEDULER_YIELD wait type is listed in the top list of the resource wait statistics query
Recover data lost due to a TRUNCATE operation
If a lot of tasks are monitored in the runnable status without backups
If the signal wait time is higher than 35% of the total resource waits
How to recover SQL Server data from accidental
If the System\% Processor Queue Length counter of the Perfmon represents greater than 3 per CPU DELETE, TRUNCATE and DROP operations
If the Processor﴾_Total﴿\%Processor Time counter of the Perfmon indicates greater 80 percentage or Reverting your SQL Server database back to a
greater values specific point in time
ASYNC_NETWORK_IO
The ASYNC_NETWORK_IO indicates two main bottlenecks that are related to the network and the network
problems affect SQL Server performance negatively. The first one is that the application requests a huge result set
but the application cannot handle the result set as fast as SQL Server due to some reasons. The second one can
be related to network infrastructure. The following suggestions may be the solution to this issue:
Review the applications and try to reduce the requested amount of data
Check the network capacities that are between client machines and SQL Server ﴾Routers, switches, NIC,
cables, etc.﴿
Validate the server NIC configurations and ensure the last driver is installed
Consider increasing the packet size property in the connection string if you are planning to send or receive
a large amount of XML or blob data.
DBAtools ﴾30﴿
DevOps ﴾22﴿
DevSecOps ﴾2﴿
Documentation ﴾19﴿
ETL ﴾56﴿
► Features ﴾201﴿
pool. PAGEIOLATCH wait type captures when the data pages fetch from the disk into the buffer pool. Most often Maintenance ﴾92﴿
time PAGEIOLATCH wait type indicates I/O problems related to the storage subsystems or memory pressure. Migration ﴾46﴿
Miscellaneous ﴾1﴿
Deadlocks ﴾15﴿
Indexes ﴾76﴿
Latches ﴾5﴿
Locking ﴾9﴿
Monitoring ﴾84﴿
Performance ﴾161﴿
Reports ﴾20﴿
When the SQL Server query optimizer decides to execute a query in parallel, it tries to divide the query operation SSAS monitoring ﴾3﴿
into equal‐sized threads as possible. CXPACKET wait type indicates the time that spends to execute a parallel SSIS monitoring ﴾10﴿
query. This wait type does not indicate any problem and can be ignored and it improves SQL Server performance.
SSRS monitoring ﴾4﴿
On the other hand, all threads cannot carry out their task exactly the same time, and the query execution time
Wait types ﴾11﴿
can be as fast as the slowest thread. When this thread’s synchronization problem reaches the unacceptable
► Professional development ﴾57﴿
amount ﴾greater than 50% of total waits﴿, we have to take into account this wait type as a problem. Possible
reasons may be as follows: Recovery ﴾32﴿
Security ﴾81﴿
Utilities ﴾18﴿
WRITELOG
SQL Server writes all modifications to the Log Buffer and its size is limited to 60KB. When Log Buffer fills up, the
log records are written into the disk and this mechanism is called Log Buffer Flush. WRITELOG wait type
indicates the elapsed time when the log records writing into the disk. The possible causes can be as below:
Locate the data files ﴾mdf,ndf﴿ and log files ﴾ldf﴿ into the separated disks
Increase the I/O capacity of the disk where the log file is placed
Consider using the Delayed Transaction Durability option of the SQL Server
Avoid the cursor which makes iterative modifications
Reducing the size of the log file
Conclusion
In this article, we learned how to boost SQL Server performance through the wait statistics. Wait statistics are the
main metrics that help to monitor and diagnose the performance problems of the SQL Server.
See more
Check out SpotLight, a free, cloud based SQL Server monitoring tool to easily detect, monitor, and solve SQL
Server performance problems on any device
Watch on
Esat Erkec
Esat Erkec is a SQL Server professional who began his career 8+ years ago as a Software
Developer. He is a SQL Server Microsoft Certified Solutions Expert.
Most of his career has been focused on SQL Server Database Administration and Development.
His current interests are in database administration and Business Intelligence. You can find him
on LinkedIn.
Related Posts:
1. All about SQL Server spinlocks
2. How to handle excessive SOS_SCHEDULER_YIELD wait type values in SQL Server
3. SQL Server Statistics and how to perform Update Statistics in SQL
4. The SQL Server 2014 Resource Governor
5. Top SQL Server Books
21,265 Views
© 2021 Quest Software Inc. ALL RIGHTS RESERVED. | GDPR | Terms of Use | Privacy