Resolving SQL Server Transaction Log Waits


What is SQL Server Wait Type?

In SQL server, wait type is a time period for which the processes stays in the local buffer. Until the log record writing process is not completed, it remains in the log buffer. It provides a high-level information of the particular process or a query on which the user is working upon. Moreover, by reducing the waits in SQL server, user can achieve the high performance of processes.

In Dynamic Management View, user can check the SQL server wait type (in milliseconds). Run the following query to do the same:

SELECT * FROM sys.dm_os_wait_stats
ORDER BY wait_time_ms DESC

After query execution, user can view many waits. However, some of these displayed waits will be system wait, i.e. SQL server wait and remaining will be useless.

What is Log Buffer?

SQL server has a small contiguous memory area in which log records are archived before permanently writing them to transaction log file in a process. Such small-sized area is named as Log Buffer. When processes like insertion, modification, and deletion take place, the server first examines the log buffer, i.e. whether any process is present in it or not.

Problem Statement

Since we have discussed earlier that the SQL waits effects the functioning of the processes therefore, a challenge arises for end-users that they will have to process the query in such a way that its wait type is low. The process should not stay in log buffer for a long time because it will degrade the performance of it. Therefore, there is a need for troubleshooting SQL server transactions log related wait type so as to improve its performance.

Workarounds to Resolve the Problem

Troubleshooting SQL Server transaction log waits is not an easy task because there are multiple aspects, which affects the transaction log files and hence, lead to increase/decrease in the performance. However, for resolving such problem it is advised to users that they should have a brief knowledge about wait type and also the causes behind waits generation.

NOTE:

  • Consider following two assumptions:
    1. A database, which is running a bulk insert
    2. Another database, which is running a workload

In both scenarios, the transaction log files related wait types would be same. The point to be noted here is that the presence of such wait types is likely to occur & won’t lead to any trouble.

  • It is being recommended to SQL server users that they must archive the log files on a separate disk for getting better performance.

To improve the performance, make use of any type of waits. Below mentioned are the types of waits (in detail), which will help users in increasing the performance of transaction log files:

(a) LOGMGR Wait Type: Such wait type occurs when the database is being terminated, due to one of the following reasons:

  • Database is in offline mode
  • Database is in read-only access mode
  • When suddenly database gets shut down

However, you will see the same type of wait when you are connected to DAC.

(b) LOGBUFFER and WRITELOG Wait Type: Both these types are identical, but not equal. Moreover, the troubleshooting procedure is likely to be same, only the difference is based upon the concept amongst them.

  • LOGBUFFER Wait Type: Such wait type occurs when a process is waiting for space in the log buffer. It calculates the time taken for generating a log record into log buffer.
  • WRITELOG Wait Type: Such wait type occurs when SQL server tries to maintain the ACID properties in it. Before writing dirty pages into data files, the server needs to write the log buffer into log file.

(c) LOGMGR_QUEUE Wait Type: When a process is waiting for completion of writing the file from log buffer to transaction log files, at that time such wait occurs. Such wait type determines and give you knowledge about the fact that whether the any log is performing its activity or not.

(d) LOGMGR_RESERVE_APPEND Wait Type: This wait type occurs when a process is examining that whether log buffer has space for writing a new log record or not. The waits type increases its value, when auto grow property is enabled in the log buffer.

Conclusion

One can learn the information about each wait type from the above-mentioned information. It is easy to resolve the issues related to wait type because it is just all about the log buffer. The functioning of log buffer plays a major role in troubleshooting SQL Server transaction log waits. Therefore, if one has a complete knowledge about workload in SQL server, wait type, and log buffer, then they may easily resolve their problem and hence, leading to increase performance.

Advertisements
This entry was posted in Home, issues and tagged , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s