<?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>checkpoints - Techyaz.com</title>
	<atom:link href="https://techyaz.com/tag/checkpoints/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>checkpoints - Techyaz.com</title>
	<link></link>
	<width>32</width>
	<height>32</height>
</image> 
	<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>
		<item>
		<title>How to Get Total Number of Virtual Log Files inside SQL Server Database Log Files?</title>
		<link>https://techyaz.com/sql-server/sql-server-administration/get-total-virtual-log-files/</link>
					<comments>https://techyaz.com/sql-server/sql-server-administration/get-total-virtual-log-files/#comments</comments>
		
		<dc:creator><![CDATA[Manvendra Deo Singh]]></dc:creator>
		<pubDate>Fri, 28 Jul 2017 10:28:42 +0000</pubDate>
				<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQL Server Administration]]></category>
		<category><![CDATA[checkpoints]]></category>
		<category><![CDATA[log_files]]></category>
		<category><![CDATA[SQL_Server_Architecture]]></category>
		<category><![CDATA[vlf]]></category>
		<guid isPermaLink="false">http://techyaz.com/?p=285</guid>

					<description><![CDATA[<p>Today, i am going to discuss about virtual log files in SQL Server and query to find number of virtual log files present in transaction log files. Related Articles: Why Should You Always Turn Off Database Auto Shrink Property? Understand&#46;&#46;&#46;</p>
<p>The post <a href="https://techyaz.com/sql-server/sql-server-administration/get-total-virtual-log-files/">How to Get Total Number of Virtual Log Files inside SQL Server Database Log Files?</a> appeared first on <a href="https://techyaz.com">Techyaz.com</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>Today, i am going to discuss about virtual log files in SQL Server and query to find number of virtual log files present in transaction log files.</p>
<p><span style="color: #800000;"><em><strong>Related Articles:</strong></em></span></p>
<ul>
<li><strong><a href="https://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></li>
<li><strong><a href="https://techyaz.com/sql-server/understanding-database-autogrowth-sql-server/" target="_blank" rel="noopener">Understand the Best Value for Database File Autogrowth Setting</a></strong></li>
<li><strong><a href="https://techyaz.com/sql-server/checkpoint/" target="_blank" rel="noopener">What is Checkpoint Process in SQL Server?</a></strong></li>
</ul>
<h3><span style="color: #000080;"><strong>Virtual Log File</strong></span></h3>
<p>As we know <a href="https://techyaz.com/sql-server/understanding-transaction-log-architecture/" target="_blank" rel="noopener"><strong>Transaction Log Files</strong></a> internally divided in to small virtual log files. Virtual Log Files also referred as VLF/VLFs. The size or number of virtual log files cannot be configured by administrators but it can be affected by number of reasons.</p>
<p>One of the reason is creating or extending log files. The size of the virtual files after a log file has been extended is the sum of the size of the existing log and the size of the new file increment. Here I will show you how VLFs will be increase when we add a new log file or increase the size of transaction log file.</p>
<p>Having large no. of virtual log files are not a good sign and can affect the performance of backup, restore and database startups. Large numbers means close to thousand or more than thousand vlfs. You will not see any visible impact if you have approx. few hundred vlfs.  I would suggest you to read <a href="https://techyaz.com/sql-server/understanding-transaction-log-architecture/" target="_blank" rel="noopener"><strong>Transaction Log File Architecture</strong></a> to understand more about this.</p>
<p>We can reduce the number of virtual log files by either Backup the Transaction Log of the database or by shrinking the Transaction Log as much as possible using DBCC SHRINKFILE.  Make sure to do this exercise during a maintenance window.</p>
<h3><span style="color: #000080;"><strong>How to Find Total Number of Virtual Log Files?</strong></span></h3>
<p>Now, I will explain how to get total number of virtual log files (VLF/VLFs) for each database on your SQL Server instance. Microsoft has introduced new DMF to monitor, alert, and avert potential transaction log issues in SQL Server 2017. Earlier we were using DBCC LOGINFO to get such information but now we can get in depth information to deal with transaction log queries with the help of this DMF.</p>
<p>The new DMF is <strong>sys.dm_db_log_info</strong> that will returns VLF information of the transaction log files.  If we will specify NULL or DEFAULT value, it will return VLF information of the current database. The built-in function DB_ID can also be specified to get details of a particular database. The sys.dm_db_log_info DMF replaces the DBCC LOGINFO statement from earlier versions.</p>
<p>Below script will show you <strong>total no. of virtual log Files for all databases</strong> hosted on a SQL Server Instance.</p>
<div class="codediv">
<pre><strong><span style="color: #0000ff;">SELECT name, count(d.database_id) as "Total_VLF_Count" from sys.databases sd
cross apply sys.dm_db_log_info(sd.database_id) d
group by name
</span></strong></pre>
</div>
<p><img fetchpriority="high" decoding="async" class="aligncenter size-full wp-image-290" src="http://techyaz.com/wp-content/uploads/2017/07/1-total-no-of-vlfs-for-all-db.jpg" alt="total no of vlfs for all db" width="783" height="294" srcset="https://techyaz.com/wp-content/uploads/2017/07/1-total-no-of-vlfs-for-all-db.jpg 783w, https://techyaz.com/wp-content/uploads/2017/07/1-total-no-of-vlfs-for-all-db-300x113.jpg 300w, https://techyaz.com/wp-content/uploads/2017/07/1-total-no-of-vlfs-for-all-db-768x288.jpg 768w" sizes="(max-width: 783px) 100vw, 783px" /></p>
<p>We can see the total no. of VLFs in each database. Now we can create a new database and check the VLF count. I have created a new database “Techyaz” and see the database file details.</p>
<div class="codediv">
<pre><strong><span style="color: #0000ff;">Create database Techyaz
GO
sp_helpdb techyaz
</span></strong></pre>
</div>
<p><img decoding="async" class="aligncenter size-full wp-image-291" src="http://techyaz.com/wp-content/uploads/2017/07/2-create-db-techyaz-sp_helpdb.jpg" alt="Create db and check files" width="906" height="397" srcset="https://techyaz.com/wp-content/uploads/2017/07/2-create-db-techyaz-sp_helpdb.jpg 906w, https://techyaz.com/wp-content/uploads/2017/07/2-create-db-techyaz-sp_helpdb-300x131.jpg 300w, https://techyaz.com/wp-content/uploads/2017/07/2-create-db-techyaz-sp_helpdb-768x337.jpg 768w" sizes="(max-width: 906px) 100vw, 906px" /></p>
<p>Now again check the total no. of VLFs by running same command which I have executed in step 1. We can see total no. of vlfs are 4 for techyaz database.</p>
<p><img decoding="async" class="aligncenter size-full wp-image-292" src="http://techyaz.com/wp-content/uploads/2017/07/3-total-vlfs-apost-techyaz-dbcreation.jpg" alt="total vlf count post techyaz db creation" width="758" height="329" srcset="https://techyaz.com/wp-content/uploads/2017/07/3-total-vlfs-apost-techyaz-dbcreation.jpg 758w, https://techyaz.com/wp-content/uploads/2017/07/3-total-vlfs-apost-techyaz-dbcreation-300x130.jpg 300w" sizes="(max-width: 758px) 100vw, 758px" /></p>
<p>Now I will increase the size of the log file and see the impact of vlf count. Run below command to increase the size of log file.</p>
<div class="codediv">
<pre><strong><span style="color: #0000ff;">USE master;
GO
ALTER DATABASE Techyaz
MODIFY FILE
(NAME = techyaz_log,
SIZE = 15MB);
</span></strong></pre>
</div>
<p><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-293" src="http://techyaz.com/wp-content/uploads/2017/07/4-Increase-file-size-of-techyaz.jpg" alt="Increase the file size by 15 MB" width="472" height="275" srcset="https://techyaz.com/wp-content/uploads/2017/07/4-Increase-file-size-of-techyaz.jpg 472w, https://techyaz.com/wp-content/uploads/2017/07/4-Increase-file-size-of-techyaz-300x175.jpg 300w" sizes="auto, (max-width: 472px) 100vw, 472px" /></p>
<p>Now again see the no. of vlfs for each database and here we can see, total no. of vlfs have been increase to 8 now.</p>
<p><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-294" src="http://techyaz.com/wp-content/uploads/2017/07/5-total-vlfs-post-size-increase.jpg" alt="total vlfs post increasing the size of log file" width="759" height="339" srcset="https://techyaz.com/wp-content/uploads/2017/07/5-total-vlfs-post-size-increase.jpg 759w, https://techyaz.com/wp-content/uploads/2017/07/5-total-vlfs-post-size-increase-300x134.jpg 300w" sizes="auto, (max-width: 759px) 100vw, 759px" /></p>
<p>Similarly we can notice the impact of vlf if we add another log file on this database. Run below command to add a log file to the database Techyaz. I kept the size of this log file is 5MB.</p>
<div class="codediv">
<pre><strong><span style="color: #0000ff;">ALTER DATABASE Techyaz
ADD LOG FILE 
(
    NAME = techyaz_log3,
    FILENAME = '/var/opt/mssql/data/Techyaz_log3.ldf',
    SIZE = 5MB,
    MAXSIZE = 100MB,
    FILEGROWTH = 5MB
)
</span></strong></pre>
</div>
<p><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-295" src="http://techyaz.com/wp-content/uploads/2017/07/6-add-log-file-to-techyaz.jpg" alt="Add Log File to techyaz db" width="800" height="318" srcset="https://techyaz.com/wp-content/uploads/2017/07/6-add-log-file-to-techyaz.jpg 800w, https://techyaz.com/wp-content/uploads/2017/07/6-add-log-file-to-techyaz-300x119.jpg 300w, https://techyaz.com/wp-content/uploads/2017/07/6-add-log-file-to-techyaz-768x305.jpg 768w" sizes="auto, (max-width: 800px) 100vw, 800px" /></p>
<p>Check and verify the newly added log file by running sp_helpdb command.</p>
<p><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-296" src="http://techyaz.com/wp-content/uploads/2017/07/7-sp_helpdb-techyaz.jpg" alt="check and verify newly added files" width="908" height="330" srcset="https://techyaz.com/wp-content/uploads/2017/07/7-sp_helpdb-techyaz.jpg 908w, https://techyaz.com/wp-content/uploads/2017/07/7-sp_helpdb-techyaz-300x109.jpg 300w, https://techyaz.com/wp-content/uploads/2017/07/7-sp_helpdb-techyaz-768x279.jpg 768w" sizes="auto, (max-width: 908px) 100vw, 908px" /></p>
<p>Check again the total vlf count for this database. Here we can see the total no of vlfs are now 12 in this database. So it is proved that vlf counts are increased if we increase the size of log file as well as we add another log file to the database.</p>
<p><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-297" src="http://techyaz.com/wp-content/uploads/2017/07/8-total-vlfs-post-file-addition.jpg" alt="Total VLF post adding log file" width="893" height="329" srcset="https://techyaz.com/wp-content/uploads/2017/07/8-total-vlfs-post-file-addition.jpg 893w, https://techyaz.com/wp-content/uploads/2017/07/8-total-vlfs-post-file-addition-300x111.jpg 300w, https://techyaz.com/wp-content/uploads/2017/07/8-total-vlfs-post-file-addition-768x283.jpg 768w" sizes="auto, (max-width: 893px) 100vw, 893px" /></p>
<p>This DMF is also useful in getting filtered output like which database have a specified no of vlf counts and what all databases that have less or more no of vlf counts of a specified value.</p>
<p>Run below command to get the name of databases which has more than 10 virtual log files. You can change the 10 value to 100 or 1000 or 10000. It is up to your requirement.</p>
<div class="codediv">
<pre><strong><span style="color: #0000ff;">SELECT name, count(d.database_id) as "Total_VLF_Count" from sys.databases sd
cross apply sys.dm_db_log_info(sd.database_id) d
group by name
having count(d.database_id)&gt;10
</span></strong></pre>
</div>
<p><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-298" src="http://techyaz.com/wp-content/uploads/2017/07/9-db-having-total-vlf-more-than10.jpg" alt="Databases that have more VLFs than specified value" width="797" height="306" srcset="https://techyaz.com/wp-content/uploads/2017/07/9-db-having-total-vlf-more-than10.jpg 797w, https://techyaz.com/wp-content/uploads/2017/07/9-db-having-total-vlf-more-than10-300x115.jpg 300w, https://techyaz.com/wp-content/uploads/2017/07/9-db-having-total-vlf-more-than10-768x295.jpg 768w" sizes="auto, (max-width: 797px) 100vw, 797px" /></p>
<p>We can see only one database has more than 10 vlfs that is techyaz which we just created. Similarly we can check about the db names which has less than 10 VLFs by running same command, just change the condition of greater than to less than.</p>
<div class="codediv">
<pre><strong><span style="color: #0000ff;">SELECT name, count(d.database_id) as "Total_VLF_Count" from sys.databases sd
cross apply sys.dm_db_log_info(sd.database_id) d
group by name
having count(d.database_id)&lt;10
</span></strong></pre>
</div>
<p><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-299" src="http://techyaz.com/wp-content/uploads/2017/07/10-db-having-total-vlf-less-than10.jpg" alt="DBs having less than 10 VLFs" width="789" height="386" srcset="https://techyaz.com/wp-content/uploads/2017/07/10-db-having-total-vlf-less-than10.jpg 789w, https://techyaz.com/wp-content/uploads/2017/07/10-db-having-total-vlf-less-than10-300x147.jpg 300w, https://techyaz.com/wp-content/uploads/2017/07/10-db-having-total-vlf-less-than10-768x376.jpg 768w" sizes="auto, (max-width: 789px) 100vw, 789px" /></p>
<p>Below is the view of all columns we can see of this DMF. This is very useful DMF and we can get all information as given below. I ran this command for database Techyaz. We can get the db id of this database from step 2 that is 6. We can also see one row for each VLF in the output as this database has 12 VLF so there are 12 rows here along with the details of each VLF.</p>
<div class="codediv">
<pre><strong><span style="color: #0000ff;">SELECT * from sys.dm_db_log_info(6)
</span></strong></pre>
</div>
<p><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-300" src="http://techyaz.com/wp-content/uploads/2017/07/11-sp_dm_db_log_info.jpg" alt="sys.dm_db_log_info output" width="1316" height="449" srcset="https://techyaz.com/wp-content/uploads/2017/07/11-sp_dm_db_log_info.jpg 1316w, https://techyaz.com/wp-content/uploads/2017/07/11-sp_dm_db_log_info-300x102.jpg 300w, https://techyaz.com/wp-content/uploads/2017/07/11-sp_dm_db_log_info-768x262.jpg 768w, https://techyaz.com/wp-content/uploads/2017/07/11-sp_dm_db_log_info-1024x349.jpg 1024w" sizes="auto, (max-width: 1316px) 100vw, 1316px" /></p>
<p>We can focus on two columns i.e. <strong>vlf_active</strong> which is 1 for first vlf and 0 for all that means it indicates whether VLF is in use or not. 0 means vlf is not in use and 1 means vlf is active so we can see only one vlf is active for this database.</p>
<p>Another is <strong>vlf_status</strong>, it indicate status of the VLF. Possible values include</p>
<p>0 &#8211; vlf is inactive<br />
1 &#8211; vlf is initialized but unused<br />
2 &#8211; vlf is active.</p>
<p>As we know this DMV is the replacement of DBCC LOGINFO so we can compare the output of both. Now run DBCC LOGINFO as see the details for database Techyaz.</p>
<p><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-301" src="http://techyaz.com/wp-content/uploads/2017/07/12-dbcc-loginfo.jpg" alt="DBCC LOGINFO output" width="806" height="455" srcset="https://techyaz.com/wp-content/uploads/2017/07/12-dbcc-loginfo.jpg 806w, https://techyaz.com/wp-content/uploads/2017/07/12-dbcc-loginfo-300x169.jpg 300w, https://techyaz.com/wp-content/uploads/2017/07/12-dbcc-loginfo-768x434.jpg 768w" sizes="auto, (max-width: 806px) 100vw, 806px" /></p>
<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><span style="color: #800000;"><em><strong>Read More:</strong></em></span></p>
<ul>
<li><strong><a href="https://techyaz.com/interview-questions/sql-server-interview-questions-answers-architecture/" target="_blank" rel="noopener">SQL Server Architecture Interview Questions &amp; Answers</a></strong></li>
<li><strong><a href="https://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></li>
<li><strong><a href="https://techyaz.com/sql-server/improve-sql-server-bulk-data-import-performance/" target="_blank" rel="noopener">How to Improve Bulk Data Load Performance?</a></strong></li>
<li><strong><a href="https://techyaz.com/sql-server/troubleshooting/fix-error-1105/" target="_blank" rel="noopener">Fix SQL Server Error 1105: Could Not Allocate Space for Object in Database because the Filegroup is Full</a></strong></li>
</ul>
<p>&nbsp;</p>
<p>The post <a href="https://techyaz.com/sql-server/sql-server-administration/get-total-virtual-log-files/">How to Get Total Number of Virtual Log Files inside SQL Server Database Log Files?</a> appeared first on <a href="https://techyaz.com">Techyaz.com</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://techyaz.com/sql-server/sql-server-administration/get-total-virtual-log-files/feed/</wfw:commentRss>
			<slash:comments>2</slash:comments>
		
		
			</item>
		<item>
		<title>What is Checkpoint Process in SQL Server?</title>
		<link>https://techyaz.com/sql-server/sql-server-administration/checkpoint/</link>
					<comments>https://techyaz.com/sql-server/sql-server-administration/checkpoint/#respond</comments>
		
		<dc:creator><![CDATA[Manvendra Deo Singh]]></dc:creator>
		<pubDate>Tue, 25 Jul 2017 17:06:07 +0000</pubDate>
				<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQL Server Administration]]></category>
		<category><![CDATA[checkpoints]]></category>
		<category><![CDATA[SQL_Server_Architecture]]></category>
		<guid isPermaLink="false">http://techyaz.com/?p=280</guid>

					<description><![CDATA[<p>Have you deep dive into SQL Server checkpoint process like what checkpoints are and how they work? Here is an article which will explain you about checkpoint process in SQL Server. What is Checkpoint Process in SQL Server? As per&#46;&#46;&#46;</p>
<p>The post <a href="https://techyaz.com/sql-server/sql-server-administration/checkpoint/">What is Checkpoint Process in SQL Server?</a> appeared first on <a href="https://techyaz.com">Techyaz.com</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>Have you deep dive into SQL Server checkpoint process like what checkpoints are and how they work? Here is an article which will explain you about checkpoint process in SQL Server.</p>
<h3><span style="color: #333399;"><strong>What is Checkpoint Process in SQL Server?</strong></span></h3>
<p>As per book online, a <em>checkpoint</em> creates a known good point from which the SQL Server Database Engine can start applying changes contained in the log during recovery after an unexpected shutdown or crash.</p>
<p>There are lot of operations run in database. If SQL Server performs any modifications to any <a href="https://techyaz.com/sql-server/understanding-sql-server-data-files-pages-extents/" target="_blank" rel="noopener">database pages</a> in memory/buffer cache, SQL Server doesn’t write these modified pages to disk after every change. Rather, SQL Server Database Engine periodically issues a checkpoint on each database and these modified pages and transaction logs in memory will be written to disk as part of checkpoint process.</p>
<h3><span style="color: #333399;"><strong>Checkpoint Types</strong></span></h3>
<p>SQL Server supports four types of checkpoints. Which checkpoint SQL Server database engine will use to write dirty pages to disk is based on their nature of operations and few configuration parameters which we set on instance level as well as database level. Below are the list of checkpoints SQL Server performs.</p>
<h5><span style="color: #993300;"><strong>Automatic Checkpoints</strong></span></h5>
<p>An automatic checkpoint occurs each time the number of log records reaches the number the Database Engine estimates it can process during the time specified in the <strong>recovery interval </strong>server configuration option. You can set the value of <strong>recovery interval</strong> using below system stored procedure.</p>
<pre><span style="color: #0000ff;"><strong>sp_configure </strong><strong>'</strong><strong>recovery interval</strong><strong>','</strong><strong><em>seconds</em></strong><strong>'</strong></span></pre>
<p>Recovery interval is maximum time that a given server instance should use to recover a database during a system restart. Database Engine estimates the maximum number of log records it can process within the recovery interval. When a database using automatic checkpoints reaches this maximum number of log records, the Database Engine issues an checkpoint on the database.</p>
<p data-lf-anchor-id="24c9e479858967aa730ecd2347204979:0">The frequency depends on the value of recovery interval option of server configuration. The time interval between automatic checkpoints can be highly variable. A database with a substantial transaction workload will have more frequent checkpoints than a database used primarily for read-only operations.</p>
<p>Database Engine generates automatic checkpoints for every database if you have not defined any value for <strong>target recovery time</strong> for a database. If you define user value for target recovery time for any database, database engine will not use automatic checkpoint and generate indirect checkpoint which I will discuss in next section.</p>
<p>Under the simple recovery model, an automatic checkpoint is also queued if the log becomes 70 percent full.</p>
<p data-lf-anchor-id="8cdd10e9b58c22e1390f9f4bc713435e:0">After a system crash, the length of time required to recover a given database depends largely on the amount of random I/O needed to redo pages that were dirty at the time of the crash. This means that the <strong>recovery interval</strong> setting is unreliable. It cannot determine an accurate recovery duration. Furthermore, when an automatic checkpoint is in progress, the general I/O activity for data increases significantly and quite unpredictably.</p>
<p>For an online transaction processing (OLTP) system using short transactions, recovery interval is the primary factor determining recovery time. However, the recovery interval option does not affect the time required to undo a long-running transaction. Recovery of a database with a long-running transaction can take much longer than the specified in the recovery interval option.</p>
<p>Typically, the <strong>default values</strong> provides optimal recovery performance. However, <strong>changing the recovery interval</strong> might improve performance in the following circumstances:</p>
<ol>
<li>If recovery routinely takes significantly longer than 1 minute when long-running transactions are not being rolled back.</li>
<li>If you notice that frequent checkpoints are impairing performance on a database.</li>
</ol>
<p>If you decide to <strong>increase the recovery interval</strong> setting, we recommend increasing it gradually by small increments and evaluating the effect of each incremental increase on recovery performance. This approach is important because as the recovery interval setting increases, database recovery takes that many times longer to complete. For example, if you change recovery interval 10 minutes, recovery takes approximately 10 times longer to complete than when recovery interval is set to 1 minute.</p>
<h5><span style="color: #993300;"><strong>Indirect Checkpoints</strong></span></h5>
<p data-lf-anchor-id="ade5f269920ba72821a71f62e5450751:0">This checkpoint was introduced in SQL Server 2012. Indirect checkpoints provide a configurable database-level alternative to automatic checkpoints. In the event of a system crash, indirect checkpoints provide potentially faster, more predictable recovery time than automatic checkpoints. We can set the TARGET_RECOVERY_TIME in Indirect checkpoint for any database by executing below ALTER DATABASE statement.</p>
<pre><span style="color: #008000;"><strong>--Change DBNAME with your database name.</strong></span>
<span style="color: #0000ff;"><strong>ALTER DATABASE DBNAME SET TARGET_RECOVERY_TIME </strong><strong>=</strong><em><strong>target_recovery_time</strong></em><strong> {SECONDS | MINUTES}</strong></span></pre>
<p>The difference between Automatic and Indirect checkpoint is, recovery interval configuration option uses the number of transactions to determine the recovery time as opposed to indirect checkpoints which makes use of number of dirty pages.</p>
<p>When indirect checkpoints are enabled on a database receiving a large number of DML operations, the background writer can start aggressively flushing dirty buffers to disk to ensure that the time required to perform recovery is within the target recovery time set of the database. This can cause additional I/O activity on certain systems which can contribute to a performance bottleneck if the disk subsystem is operating above or nearing the I/O threshold.</p>
<ol>
<li>Indirect checkpoints enable you to reliably control database recovery time by factoring in the cost of random I/O during REDO.</li>
<li>Indirect checkpoints reduce checkpoint-related I/O spiking by continually writing dirty pages to disk in the background. However, an online transactional workload on a database configured for indirect checkpoints can experience performance degradation. This is because the background writer used by indirect checkpoint sometimes increases the total write load for a server instance.</li>
</ol>
<p><strong>Indirect checkpoint is the default behavior for new databases created in SQL Server 2016</strong>. Databases which were upgraded in place or restored from a previous version of SQL Server will use the previous automatic checkpoint behavior unless explicitly altered to use indirect checkpoint.</p>
<h5><span style="color: #993300;"><strong>Manual Checkpoints</strong></span></h5>
<p>Manual checkpoint issued when you execute a T-SQL <strong>CHECKPOINT</strong> command for a database. By default, manual checkpoints run to completion. Throttling works the same way as for automatic checkpoints.</p>
<h5><span style="color: #993300;"><strong>Internal Checkpoints</strong></span></h5>
<p data-lf-anchor-id="41958c4fd5bf44f560a88f6bc725ce53:0">Internal Checkpoints are generated by various server components to guarantee that disk images match the current state of the log. Internal checkpoint are generated in response to the following events:</p>
<ol>
<li>Database files have been added or removed by using ALTER DATABASE.</li>
<li>A database backup is taken.</li>
<li>A database snapshot is created, whether explicitly or internally for DBCC CHECK.</li>
<li>An activity requiring a database shutdown is performed. For example, AUTO_CLOSE is ON and the last user connection to the database is closed, or a database option change is made that requires a restart of the database.</li>
<li>An instance of SQL Server is stopped by stopping the SQL Server (MSSQLSERVER) service. Either action causes a checkpoint in each database in the instance of SQL Server.</li>
<li>Bringing a SQL Server failover cluster instance (FCI) offline.</li>
</ol>
<h3><span style="color: #333399;"><strong>Checkpoint generated by SQL Server in different scenario</strong></span></h3>
<p>Now one question might come to your mind that how SQL Server decide which checkpoint should be used between Automatic and Indirect checkpoint if a database has <strong>target recovery time</strong> value is set to use indirect checkpoint. Below are the configuration values based on which SQL Server considers to generate either automatic checkpoint or indirect checkpoint?</p>
<ol>
<li><strong>Automatic checkpoints</strong> whose target recovery interval is 1 minute will be generated if <strong>&#8216;recovery interval&#8217; </strong>value in sp_configure command and<strong> TARGET_RECOVERY_TIME</strong> value in ALTER DATABASE command is set to 0.</li>
<li><strong>Automatic checkpoints</strong> whose target recovery interval is specified by the user defined setting of the <strong>sp_ configure recovery interval </strong>option if <strong>TARGET_RECOVERY_TIME </strong>value in ALTER DATABASE command is set to 0 and if <strong>&#8216;recovery interval&#8217; </strong>value in sp_configure command is non zero.</li>
<li><strong>Indirect checkpoints</strong> when target recovery time is determined by the <strong>TARGET_RECOVERY_TIME </strong>value in ALTER DATABASE command.</li>
</ol>
<p>You can follow attached link to understand <a href="https://techyaz.com/sql-server/understanding-transaction-log-architecture/" target="_blank" rel="noopener">SQL Server Transaction Log Architecture</a> which is also related to checkpoints topic. 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><span style="color: #800000;"><em><strong>Read More:</strong></em></span></p>
<ul>
<li><strong><a href="https://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></li>
<li><strong><a href="https://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></li>
<li><strong><a href="https://techyaz.com/sql-server/understanding-database-autogrowth-sql-server/" target="_blank" rel="noopener">understand the best value for database file autogrowth</a></strong></li>
<li><strong><a href="https://techyaz.com/interview-questions/sql-server-interview-questions-answers-architecture/" target="_blank" rel="noopener">SQL Server Architecture Interview Questions &amp; Answers</a></strong></li>
</ul>
<p>The post <a href="https://techyaz.com/sql-server/sql-server-administration/checkpoint/">What is Checkpoint Process 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-administration/checkpoint/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
