<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>transaction log - Techyaz.com</title>
	<atom:link href="https://techyaz.com/tag/transaction-log/feed/" rel="self" type="application/rss+xml" />
	<link></link>
	<description>Tips, Tutorials and How-to Topics</description>
	<lastBuildDate>Tue, 15 May 2018 15:31:55 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.8.1</generator>

<image>
	<url>https://techyaz.com/wp-content/uploads/2017/11/cropped-Site-icon-150x150.png</url>
	<title>transaction log - Techyaz.com</title>
	<link></link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Fix SQL Server Msg 5144 and 5145 for long or failed autogrow of data and log files</title>
		<link>https://techyaz.com/sql-server/troubleshooting/fix-msg-5144-and-5145-for-long-or-failed-autogrow/</link>
					<comments>https://techyaz.com/sql-server/troubleshooting/fix-msg-5144-and-5145-for-long-or-failed-autogrow/#respond</comments>
		
		<dc:creator><![CDATA[Manvendra Deo Singh]]></dc:creator>
		<pubDate>Wed, 24 Jan 2018 16:19:30 +0000</pubDate>
				<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[Troubleshooting]]></category>
		<category><![CDATA[autogrow]]></category>
		<category><![CDATA[autogrowth setting]]></category>
		<category><![CDATA[data file autogrow]]></category>
		<category><![CDATA[IFI]]></category>
		<category><![CDATA[Instant File Initialization]]></category>
		<category><![CDATA[log_files]]></category>
		<category><![CDATA[SQL_Error_Code]]></category>
		<category><![CDATA[transaction log]]></category>
		<guid isPermaLink="false">http://techyaz.com/?p=1634</guid>

					<description><![CDATA[<p>Whenever you extend the size of your data or log file with a larger value or your database perform autogrow operation to extend its database files with bigger value then SQL Server takes longer time to perform such activities. SQL&#46;&#46;&#46;</p>
<p>The post <a href="https://techyaz.com/sql-server/troubleshooting/fix-msg-5144-and-5145-for-long-or-failed-autogrow/">Fix SQL Server Msg 5144 and 5145 for long or failed autogrow of data and log files</a> appeared first on <a href="https://techyaz.com">Techyaz.com</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>Whenever you extend the size of your data or log file with a larger value or your database perform autogrow operation to extend its database files with bigger value then SQL Server takes longer time to perform such activities. SQL Server reports these messages 5144 and 5145 in to the Application Event Log and ERRORLOG in case autogrow of a database and/or transaction log file has timed out or has taken a long period of time to complete. The details about such logs are given below:</p>
<p><em><span style="color: #ff0000;">Msg 5144</span></em><br />
<em><span style="color: #ff0000;"> Autogrow of file &#8216;Data or Log file name&#8217; in database &#8216;Database&#8217; was cancelled by user or timed out after &lt;n&gt; milliseconds. Use ALTER DATABASE to set a smaller FILEGROWTH value for this file or to explicitly set a new file size.</span></em></p>
<p>Or you will get below message if autogrow operation or data/log file size increase operation will run for longer duration than expected.</p>
<p><em><span style="color: #ff0000;">Msg 5145</span></em><br />
<em><span style="color: #ff0000;"> Autogrow of file &#8216;Data or Log file name&#8217; in database &#8216;Database&#8217; took &lt;n&gt; milliseconds. Consider using ALTER DATABASE to set a smaller FILEGROWTH for this file.</span></em></p>
<p>Whenever data or log file growth operation is taking lot of time then a wait type <a href="http://techyaz.com/sql-server/reduce-wait-type-preemptive_os_writefilegather/" target="_blank" rel="noopener">PREEMPTIVE_OS_WRITEFILEGATHER</a> will be shown in to SQL Server. If you want to read more about this wait type then click at the attached link.<strong> </strong></p>
<h3><span style="color: #333399;">Root Cause</span></h3>
<p>Data and log file initialization takes lot of time if you have to create large database files or large data or log file growth will be performed. Whenever we allocate or extend space to data or log file, it first fills with zeros. Zeroing operation takes lot of time for bigger size autogrowth operations that causes for longer run to complete. We generally see these messages (5144 or 5145) during either extending the data or transaction log files or during autogrowth operation for data or log files.</p>
<p><img fetchpriority="high" decoding="async" class="size-full wp-image-1637 alignleft" src="http://techyaz.com/wp-content/uploads/2018/01/Fix-msg-5144-5145-min.png" alt="fix msg 5144 and 5145" width="560" height="315" srcset="https://techyaz.com/wp-content/uploads/2018/01/Fix-msg-5144-5145-min.png 560w, https://techyaz.com/wp-content/uploads/2018/01/Fix-msg-5144-5145-min-300x169.png 300w" sizes="(max-width: 560px) 100vw, 560px" /></p>
<p>Microsoft has given a solution named <a href="http://techyaz.com/sql-server/instant-file-initialization-enable-on-sql-server-instance/" target="_blank" rel="noopener">Instant File Initialization</a> to fix the time consuming file size allocation for data files. Once Instant File Initialization will be enabled, your data files size allocation will be done in faster way but unfortunately Instant File Initialization does not work on transaction log files.  <strong>Instant file initialization</strong> reclaims used disk space without filling that space with zeros. Instead, disk content is overwritten as new data is written to the files. Read below section to overcome these error messages.</p>
<h3><span style="color: #333399;">Solution</span></h3>
<p>To avoid these messages 5144 or 5145 to be logged, we should plan file size growth carefully. We should set maximum size of the database so that it could not perform frequent autogrowth operation. We can enable Instant File Initialization feature to speed up the data file size allocation. It is not recommended to rely on autogrowth of files as standard operation for obtaining more space in a file. Rather, you should plan out the maximum size of your database and/or transaction log file and allow autogrowth to occur only in unplanned situations for space. Follow below points to avoid this error.</p>
<ul>
<li>Enable Instant File Initialization to speed up data file size allocation. Read attached article to <a href="http://techyaz.com/sql-server/instant-file-initialization-enable-on-sql-server-instance/" target="_blank" rel="noopener">enable IFI (Instant File Initialization) on your database server</a>.</li>
<li>As IFI (Instant File Initialization) does not work on log files so we need to set log files in smaller chunks to avoid any time out error or longer runs.</li>
<li>Set database size to the maximum size it could be and allow autogrowth settings to occur only in unplanned situations for space.Read attached article to <a href="http://techyaz.com/sql-server/understanding-database-autogrowth-sql-server/" target="_blank" rel="noopener">understand Autogrowth setting and its perfect value for database files.</a></li>
</ul>
<p>I hope you like this article. Please follow our <a href="https://www.facebook.com/Techyaz/">Facebook</a> page and <a href="https://twitter.com/Tech_yaz">Twitter</a> handle to get latest updates.</p>
<p><span style="color: #800000;"><em><strong>Related Articles:</strong></em></span></p>
<ul>
<li><span style="color: #0000ff;"><strong><a style="color: #0000ff;" href="http://techyaz.com/sql-server/troubleshooting/manage-transaction-log-file-during-data-load/" target="_blank" rel="noopener">Manage Transaction Log File during Data Load</a></strong></span></li>
<li><span style="color: #0000ff;"><strong><a style="color: #0000ff;" href="http://techyaz.com/sql-server/improve-sql-server-bulk-data-import-performance/" target="_blank" rel="noopener">How to Improve Bulk Data Load Performance?</a></strong></span></li>
<li><span style="color: #0000ff;"><strong><a style="color: #0000ff;" href="http://techyaz.com/sql-server/reduce-wait-type-preemptive_os_writefilegather/" target="_blank" rel="noopener">How to Reduce SQL Server Wait type PREEMPTIVE_OS_WRITEFILEGATHER?</a></strong></span></li>
<li><span style="color: #0000ff;"><strong><a style="color: #0000ff;" href="http://techyaz.com/sql-server/always-turn-off-database-auto-shrink/" target="_blank" rel="noopener">Why Should You Always Turn Off Database Auto Shrink Property?</a></strong></span></li>
<li><span style="color: #0000ff;"><strong><a style="color: #0000ff;" href="http://techyaz.com/sql-server/troubleshooting/fix-error-3023-error-3013-error-3041/" target="_blank" rel="noopener">Fix Error 3023: Shrink failed for Log file</a></strong></span></li>
</ul>
<p>The post <a href="https://techyaz.com/sql-server/troubleshooting/fix-msg-5144-and-5145-for-long-or-failed-autogrow/">Fix SQL Server Msg 5144 and 5145 for long or failed autogrow of data and log files</a> appeared first on <a href="https://techyaz.com">Techyaz.com</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://techyaz.com/sql-server/troubleshooting/fix-msg-5144-and-5145-for-long-or-failed-autogrow/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Manage Transaction Log File during Data Load</title>
		<link>https://techyaz.com/sql-server/troubleshooting/manage-transaction-log-file-during-data-load/</link>
					<comments>https://techyaz.com/sql-server/troubleshooting/manage-transaction-log-file-during-data-load/#respond</comments>
		
		<dc:creator><![CDATA[Ganesh Bekkinkeri]]></dc:creator>
		<pubDate>Mon, 15 Jan 2018 12:58:25 +0000</pubDate>
				<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQL Server Administration]]></category>
		<category><![CDATA[Troubleshooting]]></category>
		<category><![CDATA[bulk data load]]></category>
		<category><![CDATA[data load]]></category>
		<category><![CDATA[transaction log]]></category>
		<guid isPermaLink="false">http://techyaz.com/?p=1487</guid>

					<description><![CDATA[<p>Have you even face that your transaction log file is growing exceptionally and you have to manage log file to make it in his size limit? Managing transaction log file is not an easy job if you have to run&#46;&#46;&#46;</p>
<p>The post <a href="https://techyaz.com/sql-server/troubleshooting/manage-transaction-log-file-during-data-load/">Manage Transaction Log File during Data Load</a> appeared first on <a href="https://techyaz.com">Techyaz.com</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>Have you even face that your transaction log file is growing exceptionally and you have to manage log file to make it in his size limit? Managing transaction log file is not an easy job if you have to run huge data import. I was working on a migration project where we had to import huge set of data into SQL Server database. We had changed multiple configurational parameters to <a href="http://techyaz.com/sql-server/improve-sql-server-bulk-data-import-performance/" target="_blank" rel="noopener">speed up data migration</a> and set appropriate data and log file size before starting the migration. We observed that the log file was growing extensively during data load. Log file was almost 80% full and data load was still in progress. This was a potential risk that could have caused this import to fail. We had to manage transaction log file during data load to avoid this risk and make this import successful without any issue. We had options to add log file to the database or extend the log drive. I used <a href="http://techyaz.com/sql-server/sql-server-dmvs/4-different-usages-dbcc-sqlperf-sql-server/" target="_blank" rel="noopener">DBCC SQLPERF</a> command to get the log space usage statistics. Please have a look at the log space size of database <strong>TY1</strong> in last row.</p>
<p><img decoding="async" class="aligncenter size-full wp-image-1493" src="http://techyaz.com/wp-content/uploads/2018/01/1-Check-Logspace-min.jpg" alt="Check Log File Size" width="447" height="293" srcset="https://techyaz.com/wp-content/uploads/2018/01/1-Check-Logspace-min.jpg 447w, https://techyaz.com/wp-content/uploads/2018/01/1-Check-Logspace-min-300x197.jpg 300w" sizes="(max-width: 447px) 100vw, 447px" /></p>
<p>We had few options to overcome this issue. As we were running this database in simple recovery mode, so we didn’t have an option to run the <a href="http://techyaz.com/sql-server/understanding-sql-server-backups/" target="_blank" rel="noopener">Transaction Log backup</a>. We tried to <a href="http://techyaz.com/sql-server/troubleshooting/fix-error-3023-error-3013-error-3041/" target="_blank" rel="noopener">shrink the log file to manage transaction log file</a> but it was not allowing us to do so. This might be due to the data load execution was in process and active transaction.</p>
<p>Finally, we left out with two options; either extend the log drive or add a log file to the database on a drive that has enough space to accumulate the logs. Extending the existing drive was not possible because data load was in progress and we need to fix this issue without stopping the import/data load. So, we decided to go with another option that was to add a database log file to a drive that has enough space. I have given you step by step method to add a log file to a database in below section.</p>
<h4><span style="color: #333399;">Add Log File to a Database</span></h4>
<p>I will show you how to add log file to a database using T-SQL statements and using GUI in SQL Server Management Studio to manage transaction log file during data load. This way you can manage if your transaction log file is growing faster.</p>
<p><span style="color: #ff6600;"><em><strong>Using T-SQL Statement</strong></em></span></p>
<p>Open new query window and run below T-SQL statement to add a log file <strong>TY1_Log3.ldf</strong> to database <strong>TY1</strong> on F drive. Have a look at below T-SQL code to get other details like sizing and growth details.</p>
<pre><strong><span style="color: #008000;">--Replace your Database Name and file details in below T-SQL Code.</span>
<span style="color: #0000ff;">ALTER DATABASE [TY1]
ADD LOG FILE (NAME = 'TY1_Log3', FILENAME = 'F:\TY1_Log3.ldf', SIZE = 20080 MB, FILEGROWTH = 5024 MB)
GO
</span></strong></pre>
<p>Once you execute above T-SQL statement, your log file <strong>TY1_Log3.ldf</strong> will be added on <strong>F drive</strong> to the database <strong>TY1</strong>.</p>
<p><img decoding="async" class="aligncenter wp-image-1494 size-full" src="http://techyaz.com/wp-content/uploads/2018/01/2-Add-Log-File-T-SQL-min.jpg" alt="Add log file to database" width="781" height="172" srcset="https://techyaz.com/wp-content/uploads/2018/01/2-Add-Log-File-T-SQL-min.jpg 781w, https://techyaz.com/wp-content/uploads/2018/01/2-Add-Log-File-T-SQL-min-300x66.jpg 300w, https://techyaz.com/wp-content/uploads/2018/01/2-Add-Log-File-T-SQL-min-768x169.jpg 768w" sizes="(max-width: 781px) 100vw, 781px" /></p>
<p>Remember, add the log file in a drive where you have enough space. If you will add log file to data file drive then you might face IO pressure because both data and log files will be on same drive so avoid to keep data and log file on same drive.</p>
<p><span style="color: #ff6600;"><em><strong>Using GUI in SSMS</strong></em></span></p>
<ol>
<li>Launch <strong>SQL Server Management Studio</strong> and connect to the instance of the <strong>SQL Server Database Engine</strong>. Expand <strong>Databases </strong>folder, right-click the database in which you have to add the log file, and then click <strong>Properties</strong>.</li>
<li>In the <strong>Database Properties </strong>dialog box, select the <strong>Files</strong> page from left side pane.</li>
<li>To add a transaction log file, click <strong>Add </strong>button from lower right side pane.</li>
<li>In the <strong>Database files </strong>grid, enter a logical name for the file. The file name must be unique within the database. Select the file type as <strong>log</strong>. Specify the initial size of the file. Set <strong>Autogrowth</strong> column as per your requirement.</li>
<li>Specify the path for the file location along with physical log file name. The specified path must exist before adding the file. Make sure that your drive has enough space to host this log file.</li>
<li>Click on OK button to create this add this log file to the database.</li>
</ol>
<p>Once you performed step 6, log file will be added to your database on your identified drive name. These exercises (adding log file to database) doesn&#8217;t require any downtime or it will not interrupt any existing transactions. This way you can manage transaction log file during data load if your transaction log file is growing faster.</p>
<p><span style="color: #800000;"><em><strong>Read More</strong></em></span></p>
<ul>
<li><a href="http://techyaz.com/sql-server/get-total-virtual-log-files/" target="_blank" rel="noopener">How to get Total no. of Virtual Log Files in a Transaction Log file?</a></li>
<li><a href="http://techyaz.com/sql-server/understanding-transaction-log-architecture/" target="_blank" rel="noopener">Understanding Transaction Log File Architecture</a></li>
<li><a href="http://techyaz.com/sql-server/always-turn-off-database-auto-shrink/" target="_blank" rel="noopener">Why Should You Always Turn Off Database Auto Shrink Property?</a></li>
<li><a href="http://techyaz.com/sql-server/understanding-database-autogrowth-sql-server/" target="_blank" rel="noopener">What is the best value for database file autogrowth?</a></li>
</ul>
<p>I hope you like this article. Please follow our <a href="https://www.facebook.com/Techyaz/" target="_blank" rel="noopener">Facebook</a> page and <a href="https://twitter.com/Tech_yaz">Twitter</a> handle to get latest updates.</p>
<p>The post <a href="https://techyaz.com/sql-server/troubleshooting/manage-transaction-log-file-during-data-load/">Manage Transaction Log File during Data Load</a> appeared first on <a href="https://techyaz.com">Techyaz.com</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://techyaz.com/sql-server/troubleshooting/manage-transaction-log-file-during-data-load/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>4 Different Usages of DBCC SQLPERF in SQL Server</title>
		<link>https://techyaz.com/sql-server/sql-server-dmvs/4-different-usages-dbcc-sqlperf-sql-server/</link>
					<comments>https://techyaz.com/sql-server/sql-server-dmvs/4-different-usages-dbcc-sqlperf-sql-server/#respond</comments>
		
		<dc:creator><![CDATA[Manvendra Deo Singh]]></dc:creator>
		<pubDate>Mon, 08 Jan 2018 11:02:31 +0000</pubDate>
				<category><![CDATA[DBCC & DMVs]]></category>
		<category><![CDATA[Performance Tuning]]></category>
		<category><![CDATA[Wait Types]]></category>
		<category><![CDATA[DBCC]]></category>
		<category><![CDATA[dmv]]></category>
		<category><![CDATA[latches]]></category>
		<category><![CDATA[log space]]></category>
		<category><![CDATA[log_files]]></category>
		<category><![CDATA[transaction log]]></category>
		<category><![CDATA[wait statistics]]></category>
		<category><![CDATA[Waittypes]]></category>
		<guid isPermaLink="false">http://techyaz.com/?p=1445</guid>

					<description><![CDATA[<p>DBCC SQLPERF is very useful command that we use to get multiple statistics related information in SQL Server. This command provides transaction log space statistics and wait statistics information at instance level and we also use it to reset wait and&#46;&#46;&#46;</p>
<p>The post <a href="https://techyaz.com/sql-server/sql-server-dmvs/4-different-usages-dbcc-sqlperf-sql-server/">4 Different Usages of DBCC SQLPERF in SQL Server</a> appeared first on <a href="https://techyaz.com">Techyaz.com</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>DBCC SQLPERF is very useful command that we use to get multiple statistics related information in SQL Server. This command provides <a href="http://techyaz.com/sql-server/understanding-transaction-log-architecture/" target="_blank" rel="noopener">transaction log</a> space statistics and wait statistics information at instance level and we also use it to reset wait and latch statistics data. We can use DBCC SQLPERF command to do below tasks.</p>
<ol>
<li>Get log space size</li>
<li>View wait statistics data</li>
<li>Clear wait statistics data</li>
<li>Clear latch statistics data</li>
</ol>
<p>Let’s discuss each of above tasks as use cases of DBCC SQLPERF command.</p>
<p><em><strong><span style="color: #800000;">Read More</span></strong></em></p>
<ul>
<li><a href="http://techyaz.com/sql-server/get-total-virtual-log-files/" target="_blank" rel="noopener">How to get total no of VLFs (Virtual Log Files) inside Log file?</a></li>
<li><a href="http://techyaz.com/sql-server/understanding-sql-server-data-files-pages-extents/" target="_blank" rel="noopener">Understanding Data Files, Pages &amp; Extents</a></li>
<li><a href="http://techyaz.com/sql-server/how-to-avoid-page-split-in-sql-server/" target="_blank" rel="noopener">How to Avoid Page Split in SQL Server?</a></li>
</ul>
<h4><span style="color: #333399;">Get Transaction Log space using DBCC SQLPERF</span></h4>
<p>We can get transaction log space utilization details like how large your transaction logs are and what percentage of them is in use by executing dbcc sqlperf command. Run below command to get the log space details of all database hosted your SQL Server Instance.</p>
<div class="codediv">
<pre><strong><span style="color: #008000;">--Get Transaction Log Size Details</span>
<span style="color: #0000ff;">DBCC SQLPERF(logspace)
</span></strong></pre>
</div>
<p>You can see the below screenshot; all the columns are self-explanatory. We can see percent of log space used out of total space allocated to the log file.</p>
<p><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-1447" src="http://techyaz.com/wp-content/uploads/2018/01/1-Check-log-space.jpg" alt="Check Log space utilization using dbcc sqlperf" width="417" height="236" srcset="https://techyaz.com/wp-content/uploads/2018/01/1-Check-log-space.jpg 417w, https://techyaz.com/wp-content/uploads/2018/01/1-Check-log-space-300x170.jpg 300w" sizes="auto, (max-width: 417px) 100vw, 417px" /></p>
<h4><span style="color: #333399;">View and Clear Wait Statistics Data</span></h4>
<p>We can get wait statistics data using dbcc sqlperf command as well. We used to get these details using dbcc sqlperf command in older version of SQL Server instances. Although, you can still get wait statistics data using this command in current versions of SQL Server but now there is a better way to get such details using DMV <strong>sys.dm_os_wait_stats</strong>.  Here, I will show you wait stats data using DMV only. Run below commands to get wait statistics details of your SQL Server instance.</p>
<div class="codediv">
<pre><strong><span style="color: #008000;">--Get wait Statistics using DBCC command.</span>
DBCC SQLPERF(waitstats)

<span style="color: #008000;">--Get Wait Statistics using DMV sys.dm_os_wait_stats</span>
SELECT * FROM sys.dm_os_wait_stats
Order by wait_time_ms desc
</strong></pre>
</div>
<p>You can see the details about all wait types on your SQL Server instance. You can also see the total wait time in milliseconds. These information is very important to deal with performance issues but details like total wait time, total waiting tasks count are not the real-time values. These values are accumulated since last SQL Server service start or last time wait stats was reset using dbcc sqlperf command. It is highly recommended to not clear wait stats data until it is required to do that otherwise you will lose valuable information about wait statistics. Read attached article about <a href="http://techyaz.com/sql-server/sql-server-dmvs/clear-wait-statistics-data-sql-server/" target="_blank" rel="noopener">why should you not clear wait statistics data stored in DMV sys.dm_os_wait_stats</a>.</p>
<p><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-1448" src="http://techyaz.com/wp-content/uploads/2018/01/2-sys.dm_os_wait_stats.jpg" alt="View Wait stats data using DMV" width="643" height="300" srcset="https://techyaz.com/wp-content/uploads/2018/01/2-sys.dm_os_wait_stats.jpg 643w, https://techyaz.com/wp-content/uploads/2018/01/2-sys.dm_os_wait_stats-300x140.jpg 300w" sizes="auto, (max-width: 643px) 100vw, 643px" /></p>
<p>If you want to get the correct waiting task counts or waiting time then you need to clear the wait statistics data using dbcc sqlperf command. Here, I will show you the difference after clearing the wait stats. Run below command to clear all wait stats data on your SQL Server Instance.</p>
<div class="codediv">
<pre><strong>DBCC SQLPERF(“sys.dm_os_wait_stats”, CLEAR)
</strong></pre>
</div>
<p>You can see I have successfully ran this command in below screenshot.</p>
<p><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-1449" src="http://techyaz.com/wp-content/uploads/2018/01/3-Clear-buffer-for-wait-stats.jpg" alt="clear wait stats" width="689" height="121" srcset="https://techyaz.com/wp-content/uploads/2018/01/3-Clear-buffer-for-wait-stats.jpg 689w, https://techyaz.com/wp-content/uploads/2018/01/3-Clear-buffer-for-wait-stats-300x53.jpg 300w" sizes="auto, (max-width: 689px) 100vw, 689px" /></p>
<p>Now we will again run same command to get the wait statistics data. I ran it and I get below data that is showing different than the one showing before clearing wait stats. This way you can better analyze your database performance and waiting tasks and time to reach on any conclusion.</p>
<p><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-1450" src="http://techyaz.com/wp-content/uploads/2018/01/4-Check-wait-stats-after-clearning-buffer.jpg" alt="Check wait stats after clearing its buffer" width="804" height="283" srcset="https://techyaz.com/wp-content/uploads/2018/01/4-Check-wait-stats-after-clearning-buffer.jpg 804w, https://techyaz.com/wp-content/uploads/2018/01/4-Check-wait-stats-after-clearning-buffer-300x106.jpg 300w, https://techyaz.com/wp-content/uploads/2018/01/4-Check-wait-stats-after-clearning-buffer-768x270.jpg 768w" sizes="auto, (max-width: 804px) 100vw, 804px" /></p>
<p>&nbsp;</p>
<h4><span style="color: #333399;">Clear Latch Statistics Data</span></h4>
<p>I described about clearing wait stats data in above section. Here, I will show you how to clear latch statistics data. <b>Latches</b> are locks for RAM memory structures to prevent concurrent access and ensure serial execution of kernel code. You can run SQL command to check current latch statistics data.</p>
<div class="codediv">
<pre><span style="color: #008000;"><span style="color: #008000;"><b>--Get latch statistics data</b></span></span><b>
SELECT * FROM sys.dm_os_latch_stats
ORDER BY wait_time_ms desc
</b></pre>
</div>
<p>You can see current latch statistics details that is also not showing only real time value but it is accumulated data since last SQL Server service restarted or last time latch wait statistics was reset/cleared.</p>
<p><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-1451" src="http://techyaz.com/wp-content/uploads/2018/01/5-Check-Latch.jpg" alt="Get Latch Statistics Data" width="678" height="217" srcset="https://techyaz.com/wp-content/uploads/2018/01/5-Check-Latch.jpg 678w, https://techyaz.com/wp-content/uploads/2018/01/5-Check-Latch-300x96.jpg 300w" sizes="auto, (max-width: 678px) 100vw, 678px" /></p>
<p>&nbsp;</p>
<p>Now we will clear these latch statistics data to get real time value of latch details. Run below dbcc sqlperf command to clear the latch statistics.</p>
<div class="codediv">
<pre><strong>DBCC SQLPERF(“sys.dm_os_latch_stats”, CLEAR)
</strong></pre>
</div>
<p>You can see we have successfully executed above command on our SQL Server Instance.</p>
<p><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-1452" src="http://techyaz.com/wp-content/uploads/2018/01/6-Clear-stored-latch-details.jpg" alt="Clear Latch Statistics Data" width="722" height="121" srcset="https://techyaz.com/wp-content/uploads/2018/01/6-Clear-stored-latch-details.jpg 722w, https://techyaz.com/wp-content/uploads/2018/01/6-Clear-stored-latch-details-300x50.jpg 300w" sizes="auto, (max-width: 722px) 100vw, 722px" /></p>
<p>Now go ahead and run same SQL command to get the latch statistics again. You can see now there is no waiting requests on our SQL Server Instance and you are getting real time value about latches.</p>
<p><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-1453" src="http://techyaz.com/wp-content/uploads/2018/01/7-check-latch-details-after-clearning-buffer.jpg" alt="latch details after cleaning its buffer data " width="677" height="197" srcset="https://techyaz.com/wp-content/uploads/2018/01/7-check-latch-details-after-clearning-buffer.jpg 677w, https://techyaz.com/wp-content/uploads/2018/01/7-check-latch-details-after-clearning-buffer-300x87.jpg 300w" sizes="auto, (max-width: 677px) 100vw, 677px" /></p>
<p><em><strong><span style="color: #800000;">Related Articles</span></strong></em></p>
<ul>
<li><a href="http://techyaz.com/sql-server/sql-server-dmvs/clear-wait-statistics-data-sql-server/" target="_blank" rel="noopener">Should We Clear Wait Stats Data from DMV sys.dm_os_wait_stats?</a></li>
<li><a href="http://techyaz.com/sql-server/backupbuffer-wait-type/" target="_blank" rel="noopener">How to Fix BACKUPBUFFER Wait Type?</a></li>
<li><a href="http://techyaz.com/sql-server/improve-sql-server-bulk-data-import-performance/" target="_blank" rel="noopener">How to Improve Bulk Data Load Performance?</a></li>
</ul>
<p>These are the 4 use cases of DBCC SQLPERF command that we use during different database activities. I hope you like this article. Please follow our <a href="https://www.facebook.com/Techyaz/">Facebook</a> page and <a href="https://twitter.com/Tech_yaz">Twitter </a>handle to get latest updates.</p>
<p>The post <a href="https://techyaz.com/sql-server/sql-server-dmvs/4-different-usages-dbcc-sqlperf-sql-server/">4 Different Usages of DBCC SQLPERF in SQL Server</a> appeared first on <a href="https://techyaz.com">Techyaz.com</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://techyaz.com/sql-server/sql-server-dmvs/4-different-usages-dbcc-sqlperf-sql-server/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Understanding SQL Server Recovery Model</title>
		<link>https://techyaz.com/sql-server/backup-recovery/understanding-sql-server-recovery-model/</link>
					<comments>https://techyaz.com/sql-server/backup-recovery/understanding-sql-server-recovery-model/#comments</comments>
		
		<dc:creator><![CDATA[Manvendra Deo Singh]]></dc:creator>
		<pubDate>Sat, 09 Sep 2017 12:00:07 +0000</pubDate>
				<category><![CDATA[Backup & Recovery]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQL Server Administration]]></category>
		<category><![CDATA[Backups]]></category>
		<category><![CDATA[bulk-logged]]></category>
		<category><![CDATA[checkpoints]]></category>
		<category><![CDATA[full]]></category>
		<category><![CDATA[log_files]]></category>
		<category><![CDATA[recovery]]></category>
		<category><![CDATA[Recovery Model]]></category>
		<category><![CDATA[simple]]></category>
		<category><![CDATA[transaction log]]></category>
		<guid isPermaLink="false">http://techyaz.com/?p=829</guid>

					<description><![CDATA[<p>A Recovery Model is a database property that designed to control transaction log maintenance. SQL Server Recovery Model does not define how transactions will be logged but they define how transaction logs will be managed in the transaction log file.&#46;&#46;&#46;</p>
<p>The post <a href="https://techyaz.com/sql-server/backup-recovery/understanding-sql-server-recovery-model/">Understanding SQL Server Recovery Model</a> appeared first on <a href="https://techyaz.com">Techyaz.com</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>A Recovery Model is a database property that designed to control transaction log maintenance. SQL Server Recovery Model does not define how transactions will be logged but they define how transaction logs will be managed in the <a href="https://techyaz.com/sql-server/understanding-transaction-log-architecture/" target="_blank" rel="noopener">transaction log file</a>. There are three types of recovery models in SQL Server:</p>
<ul>
<li>Simple</li>
<li>Full</li>
<li>Bulk-Logged</li>
</ul>
<h3><span style="color: #000080;">Simple Recovery Model</span></h3>
<p>Simple recovery model is used for databases that are not critical or the database is static and data is not changing. We generally use SIMPLE model for lower life cycle databases. Main reason for this is point in time recovery is not possible because transaction log backup is not allowed in this recovery model and database engine automatically clears transactional logs during checkpoint operation. If you want to <a href="https://techyaz.com/sql-server/checkpoint/" target="_blank" rel="noopener">understand checkpoint operation</a>, you should read attached article.</p>
<p>A common <strong>myth</strong> is that when a database is configured in Simple recovery model then transactions will not be logged in transaction log files. This is not true and <strong>every transaction is logged to the transaction log file</strong>. Only difference is that, when that <strong>transactions will complete</strong> and data is written to disk all <strong>logs will flush</strong> and be available to log another transaction in same log file. This way you can also deal with the space issue.</p>
<p>Log Shipping, <a href="https://techyaz.com/sql-server/alwayson-availability-group/" target="_blank" rel="noopener">AlwaysOn Availability group</a> and <a href="https://techyaz.com/sql-server/point-in-time-recovery/" target="_blank" rel="noopener">Point-in-Time Restores</a> are not possible in this SIMPLE model because transaction log backups are not allowed in this recovery model. We can recover any database that are running in SIMPLE model till last full or differential backups only. Run below command if you want to view or change the recovery model of the database.</p>
<pre class="brush: sql; title: ; notranslate" title=""><strong><span class="kwrd" style="color: blue;"><span style="color: #008000;">--Check the Recovery Model of the database YourDB_Name
<span style="color: #0000ff;">SELECT name, recovery_model_desc  
   FROM sys.databases  
      WHERE name = 'YOURDB_NAME' ;  
GO</span>
--Change Recovery Model to SIMPLE</span>
ALTER DATABASE DBNAME SET RECOVERY SIMPLE
GO
</span></strong></pre>
<h3><span style="color: #000080;">Full Recovery Model</span></h3>
<p><a href="https://techyaz.com/sql-server/point-in-time-recovery/" target="_blank" rel="noopener">Point in time recovery</a> is possible in full recovery model that is why we use this recovery model for all production and critical databases. Every transactions that are logged in this recovery model can be backed up. Transaction log backup will capture all the logs and clears all the inactive portions of the transaction log file.  You can handle your <a href="https://techyaz.com/sql-server/get-total-virtual-log-files/" target="_blank" rel="noopener">log file space management</a> by scheduling frequent transaction log backups.</p>
<p>You can also clear the transaction logs from log files by switching the recovery model from Full to Simple but this is never recommended for any production database. If you change the SQL Server recovery model from Full to Simple, logs will be flushed from log file without getting captured into transaction log backup. That will break the log sequence and you will end up losing the point in time recovery for your database. That is why switching recovery model from full to simple is not recommended for production database.</p>
<p>As transaction log backups are allowed in this recovery model so you can recover your database till point in time and there will be no data loss in this recovery model.</p>
<pre class="brush: sql; title: ; notranslate" title=""><strong><span class="kwrd" style="color: blue;"><span style="color: #008000;">--Change SQL Server Recovery Model to FULL</span>
ALTER DATABASE DBNAME SET RECOVERY FULL
GO
</span></strong></pre>
<h3><span style="color: #000080;">Bulk-Logged Recovery Model</span></h3>
<p>Bulk-logged recovery model works similar to Full recovery model except few exceptions during bulk operations. You can use this recovery model if you have to run BULK operations on your database. Bulk-logged recovery model minimally logged such bulk operations to reduce the transaction log space.</p>
<p>Point in time recovery is not possible if you have performed any bulk operation during that time due to the nature of minimally logged operation. If you haven&#8217;t performed any bulk operation then point in time recovery can be achieved. Microsoft does not suggest to run any database in bulk-logged recovery model if you don&#8217;t have to run any bulk operations.</p>
<p>Best practice is that you change a database recovery model to the bulk-logged immediately before running bulk operations and restore it back to the full recovery model when those operations complete. Also you should run a log backup before switching to bulk-logged recovery model and again take the log backup once you return back to full recovery model post completing bulk operation. Your backup strategy remains the same and it will not break your log sequence. Run below command to change the recovery model to bulk-logged.</p>
<pre class="brush: sql; title: ; notranslate" title=""><strong><span class="kwrd" style="color: blue;"><span style="color: #008000;">--Change Recovery Model to BULK-Logged</span>
ALTER DATABASE DBNAME SET RECOVERY FULL
GO
</span></strong></pre>
<h3><span style="color: #000080;">Change Recovery Model using GUI</span></h3>
<ol>
<li>Connect to SQL Server Instance. in Object Explorer, click the server name to expand the server tree.</li>
<li>Expand <strong>Databases</strong> folder and click on the database for which either you want to change the recovery model of view the recovery model.</li>
<li>Right-click on that database, and then click <strong>Properties</strong>, which opens the <strong>Database Properties</strong> dialog box.</li>
<li>In the <strong>Select a page</strong> pane, click <strong>Options</strong>.</li>
<li>The current recovery model is displayed in the <strong>Recovery model</strong> list box.</li>
<li>Optionally, to change the recovery model select a different model list. The choices are <strong>Full</strong>, <strong>Bulk-logged</strong>, or <strong>Simple</strong>.</li>
<li>Click <strong>OK</strong>.</li>
</ol>
<p>I hope you like this article. Please follow us on our <a href="https://www.facebook.com/Techyaz/">facebook page</a> and on <a href="https://twitter.com/Tech_yaz">Twitter </a>handle to get latest updates.</p>
<p>The post <a href="https://techyaz.com/sql-server/backup-recovery/understanding-sql-server-recovery-model/">Understanding SQL Server Recovery Model</a> appeared first on <a href="https://techyaz.com">Techyaz.com</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://techyaz.com/sql-server/backup-recovery/understanding-sql-server-recovery-model/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
			</item>
	</channel>
</rss>
