<?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>SQL_Server_Architecture - Techyaz.com</title>
	<atom:link href="https://techyaz.com/tag/sql_server_architecture/feed/" rel="self" type="application/rss+xml" />
	<link></link>
	<description>Tips, Tutorials and How-to Topics</description>
	<lastBuildDate>Fri, 23 Jul 2021 12:29:27 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.8</generator>

<image>
	<url>https://techyaz.com/wp-content/uploads/2017/11/cropped-Site-icon-150x150.png</url>
	<title>SQL_Server_Architecture - Techyaz.com</title>
	<link></link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Understanding SQL Server Indexes</title>
		<link>https://techyaz.com/sql-server/indexes/understanding-sql-server-indexes/</link>
					<comments>https://techyaz.com/sql-server/indexes/understanding-sql-server-indexes/#respond</comments>
		
		<dc:creator><![CDATA[Manvendra Deo Singh]]></dc:creator>
		<pubDate>Thu, 09 Nov 2017 10:50:08 +0000</pubDate>
				<category><![CDATA[Indexes]]></category>
		<category><![CDATA[Performance Tuning]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[Clustered Index]]></category>
		<category><![CDATA[Index]]></category>
		<category><![CDATA[Nonclustered Index]]></category>
		<category><![CDATA[SQL Server Indexes]]></category>
		<category><![CDATA[SQL_Server_Architecture]]></category>
		<guid isPermaLink="false">http://techyaz.com/?p=1114</guid>

					<description><![CDATA[<p>SQL Server Indexes are similar to book indexes that we use to search any content in that book. They are very useful in faster data retrieval or data access. We create index on columns of tables or views. An index is&#46;&#46;&#46;</p>
<p>The post <a href="https://techyaz.com/sql-server/indexes/understanding-sql-server-indexes/">Understanding SQL Server Indexes</a> appeared first on <a href="https://techyaz.com">Techyaz.com</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>SQL Server Indexes are similar to book indexes that we use to search any content in that book. They are very useful in faster data retrieval or data access. We create index on columns of tables or views. An index is made up of a set of pages (index nodes) that are organized in a B-tree structure. A B-tree structure has three levels.</p>
<ul>
<li>Root Level</li>
<li>Intermediate Level</li>
<li>leaf Level.</li>
</ul>
<p>Clustered index leaf-level pages contain the data in the table whereas Non Clustered index leaf-level pages contain the key value and a pointer to the data row in the clustered index or heap.</p>
<p><span style="color: #800000;"><em><strong>Read More</strong></em></span></p>
<ul>
<li><strong><a href="https://techyaz.com/sql-server/use-resumable-online-index-rebuild-operation-sql-server/" target="_blank" rel="noopener">How to use Resumable Online Index Rebuild Operation?</a></strong></li>
<li><strong><a href="https://techyaz.com/sql-server/performing-online-index-rebuild-operation/" target="_blank" rel="noopener">Understanding Online Index Rebuild Operation</a></strong></li>
<li><strong><a href="https://techyaz.com/sql-server/sql-server-interview-questions-answers-indexes/attachment/sql-server-interview-questions-and-answers-on-indexes/" target="_blank" rel="noopener">SQL Server Interview Questions &amp; Answers on Indexes</a></strong></li>
</ul>
<p>If your table does not have SQL Server indexes and you want to access data from the table then database engine will take more time and performance because full table scan will be performed to get that data. However, if your table has an index on column, SQL Server can seek directly on the value and retrieve the rows.</p>
<p><img fetchpriority="high" decoding="async" class="wp-image-1116 size-medium alignleft" src="http://techyaz.com/wp-content/uploads/2017/11/Index-e1510224779231-300x249.jpg" alt="SQL Server Index" width="300" height="249" srcset="https://techyaz.com/wp-content/uploads/2017/11/Index-e1510224779231-300x249.jpg 300w, https://techyaz.com/wp-content/uploads/2017/11/Index-e1510224779231.jpg 719w" sizes="(max-width: 300px) 100vw, 300px" /></p>
<h4><span style="color: #333399;">Index Types</span></h4>
<p>There are multiple types of indexes in SQL Server. Below is the list of such indexes.</p>
<h5><span style="color: #800000;">Clustered Index</span></h5>
<ul>
<li>Clustered indexes sort and store the data rows in the table or view based on their key values. There can be only one clustered index per table, because the data rows themselves can be sorted in only one order.</li>
<li>The only time the data rows in a table are stored in sorted order is when the table contains a clustered index. When a table has a clustered index, the table is called a clustered table. If a table has no clustered index, its data rows are stored in an unordered structure called a heap.</li>
</ul>
<h5><span style="color: #800000;">Nonclustered Index</span></h5>
<ul>
<li>Nonclustered indexes have the same B-tree structure as clustered indexes.</li>
<li>The data rows of the underlying table are not sorted and stored in order based on their nonclustered keys.</li>
<li>The leaf layer of a nonclustered index is made up of index pages instead of data pages.</li>
<li>You can create upto 999 nonclustered indexes on a table.</li>
</ul>
<h5><span style="color: #800000;">Memory-optimized nonclustered indexes</span></h5>
<ul>
<li>For memory-optimized nonclustered indexes, memory consumption is a function of the row count and the size of the index key columns</li>
</ul>
<h5><span style="color: #800000;">Hash Index</span></h5>
<ul>
<li>With a hash index, data is accessed through an in-memory hash table. Hash indexes consume a fixed amount of memory, which is a function of the bucket count.</li>
</ul>
<h5><span style="color: #800000;">Unique  Index</span></h5>
<ul>
<li>A unique index ensures that the index key contains no duplicate values and therefore every row in the table or view is in some way unique. Uniqueness can be a property of both clustered and nonclustered indexes.</li>
</ul>
<h5><span style="color: #800000;">Columnstore Index</span></h5>
<ul>
<li>An in-memory columnstore index stores and manages data by using column-based data storage and column-based query processing.</li>
<li>Columnstore indexes work well for data warehousing workloads that primarily perform bulk loads and read-only queries.</li>
<li>Use the columnstore index to achieve up to 10x query performance gains over traditional row-oriented storage, and up to 7x data compression over the uncompressed data size.</li>
</ul>
<h5><span style="color: #800000;">Index with included columns</span></h5>
<ul>
<li>A nonclustered index that is extended to include nonkey columns in addition to the key columns.</li>
</ul>
<h5><span style="color: #800000;">Index on computed columns  </span></h5>
<ul>
<li>An index on a column that is derived from the value of one or more other columns, or certain deterministic inputs.</li>
</ul>
<h5><span style="color: #800000;">Filtered Index</span></h5>
<ul>
<li>An optimized nonclustered index, especially suited to cover queries that select from a well-defined subset of data. It uses a filter predicate to index a portion of rows in the table. A well-designed filtered index can improve query performance, reduce index maintenance costs, and reduce index storage costs compared with full-table indexes.</li>
</ul>
<h5><span style="color: #800000;">Spatial  Index</span></h5>
<ul>
<li>A spatial index provides the ability to perform certain operations more efficiently on spatial objects (spatial data) in a column of the geometry data type. The spatial index reduces the number of objects on which relatively costly spatial operations need to be applied.</li>
</ul>
<h5><span style="color: #800000;">XML Index</span></h5>
<ul>
<li>A shredded, and persisted, representation of the XML binary large objects (BLOBs) in the xml data type column.</li>
</ul>
<h5><span style="color: #800000;">Full-text Index</span></h5>
<ul>
<li>A special type of token-based functional index that is built and maintained by the Microsoft Full-Text Engine for SQL Server. It provides efficient support for sophisticated word searches in character string data.</li>
</ul>
<h4><span style="color: #333399;">How SQL Server Indexes are used by Query Optimizer</span></h4>
<p>When a query is executed, the query optimizer evaluates each available method for retrieving the data and selects the most efficient method. The method may be a table scan, or may be scanning one or more indexes if they exist. When performing a table scan, the query optimizer reads all the rows in the table, and extracts the rows that meet the criteria of the query. A table scan generates many disk I/O operations and can be resource intensive. However, a table scan could be the most efficient method if, for example, the result set of the query is a high percentage of rows from the table.</p>
<p>When the query optimizer uses an index, it searches the index key columns, finds the storage location of the rows needed by the query and extracts the matching rows from that location. Generally, searching the index is much faster than searching the table because unlike a table, an index frequently contains very few columns per row and the rows are in sorted order.</p>
<p>Your task is to design and create SQL Server indexes that are best suited to your environment so that the query optimizer has a selection of efficient indexes from which to select. SQL Server provides the Database Engine Tuning Advisor to help with the analysis of your database environment and in the selection of appropriate indexes.</p>
<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>The post <a href="https://techyaz.com/sql-server/indexes/understanding-sql-server-indexes/">Understanding SQL Server Indexes</a> appeared first on <a href="https://techyaz.com">Techyaz.com</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://techyaz.com/sql-server/indexes/understanding-sql-server-indexes/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>What is Instant File Initialization and How to enable it on SQL Server Instance?</title>
		<link>https://techyaz.com/sql-server/sql-server-administration/instant-file-initialization-enable-on-sql-server-instance/</link>
					<comments>https://techyaz.com/sql-server/sql-server-administration/instant-file-initialization-enable-on-sql-server-instance/#respond</comments>
		
		<dc:creator><![CDATA[Manvendra Deo Singh]]></dc:creator>
		<pubDate>Thu, 07 Sep 2017 08:40:38 +0000</pubDate>
				<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQL Server Administration]]></category>
		<category><![CDATA[data file]]></category>
		<category><![CDATA[HowTO]]></category>
		<category><![CDATA[Instant File Initialization]]></category>
		<category><![CDATA[SQL Server Configuration Manager]]></category>
		<category><![CDATA[SQL_Server_Architecture]]></category>
		<guid isPermaLink="false">http://techyaz.com/?p=820</guid>

					<description><![CDATA[<p>Instant file initialization is very useful feature to speedup the process of increasing or allocating data file space of a SQL Server database. Have you ever thought how SQL Server initialized its database files during space allocation? General way to&#46;&#46;&#46;</p>
<p>The post <a href="https://techyaz.com/sql-server/sql-server-administration/instant-file-initialization-enable-on-sql-server-instance/">What is Instant File Initialization and How to enable it on SQL Server Instance?</a> appeared first on <a href="https://techyaz.com">Techyaz.com</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p><strong>Instant file initialization</strong> is very useful feature to speedup the process of increasing or allocating data file space of a SQL Server database. Have you ever thought how SQL Server initialized its database files during space allocation? General way to initialize any data and log files is to filling the files with zeros to overwrite any existing data left on the disk from previously deleted files. Data and log file initialization happen during space allocation activities such as database creation, adding any database files, Autogrow operation or increasing the size of any database files and backup file creating.</p>
<p>Read more about auto growth and auto shrink operation in SQL Server. Both are very important activity you should review to improve your database performance.</p>
<ul>
<li><strong><a href="https://techyaz.com/sql-server/understanding-database-autogrowth-sql-server/" target="_blank" rel="noopener">Understanding Database Autogrowth in SQL Server</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>
</ul>
<h2>What is Instant File Initialization?</h2>
<p>Data and log file initialization takes lot of time if you have to create large database files. This can also increase total completion time of large database restore or large amount of data import to the SQL Server. Microsoft has given a feature called <strong>Instant file initialization</strong> that allows fast data file allocations for all data file operations. This feature reclaims used disk space without filling that space with zeros. Instead, disk content is overwritten as new data is written to the files. But unfortunately, this feature <strong>doesn&#8217;t work with log files</strong> so they cannot be initialized instantaneously. This is not enterprise feature any SQL Server edition can use it.</p>
<p>As we know <strong>DELETE operation</strong> deallocates the space and a new allocation can reuse that space which may still have data in it. When we do not zero out the existing space in case of instant file initialization there is a possibility that someone could read data that you thought had been deleted. This is a <strong>known security risk</strong> of this feature that must be considered while enabling it for your SQL Server Instance. Instant File Initialization is not enabled by default in SQL Server because of this security risk.</p>
<h3>Enable Instant File Initialization for SQL Server?</h3>
<p>Below are the steps you need to perform to enable Instant File Initialization.</p>
<p><strong>Step 1-</strong> Login to server where you want to enable Instant File Initialization. This might be your database server or backup server.<br /><strong>Step 2-</strong> Open the <strong>Local Security Policy</strong> application. You can go to <strong>Control Panel-&gt;Administrative Tools-&gt;Local Security Policy</strong>. You can also open it directly by putting <strong>secpol.msc</strong> into run command prompt.</p>
<p><img decoding="async" class="aligncenter size-full wp-image-821" src="http://techyaz.com/wp-content/uploads/2017/09/1-run.jpg" alt="Open Local Security Policy by running secpol.msc" width="461" height="241" srcset="https://techyaz.com/wp-content/uploads/2017/09/1-run.jpg 461w, https://techyaz.com/wp-content/uploads/2017/09/1-run-300x157.jpg 300w" sizes="(max-width: 461px) 100vw, 461px" /></p>
<p><strong>Step 3-</strong> In the left pane, expand <strong>Local Policies</strong>, and then click <strong>User Rights Assignment</strong>.</p>
<p><img decoding="async" class="aligncenter size-full wp-image-822" src="http://techyaz.com/wp-content/uploads/2017/09/2-local-policy.jpg" alt="local security policy " width="664" height="576" srcset="https://techyaz.com/wp-content/uploads/2017/09/2-local-policy.jpg 664w, https://techyaz.com/wp-content/uploads/2017/09/2-local-policy-300x260.jpg 300w" sizes="(max-width: 664px) 100vw, 664px" /><br /><strong>Step 4-</strong> In the right pane, double-click <strong>Perform volume maintenance tasks</strong>.</p>
<p><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-823" src="http://techyaz.com/wp-content/uploads/2017/09/3-local-policy.jpg" alt="Enable Instant file Initialization" width="558" height="542" srcset="https://techyaz.com/wp-content/uploads/2017/09/3-local-policy.jpg 558w, https://techyaz.com/wp-content/uploads/2017/09/3-local-policy-300x291.jpg 300w" sizes="auto, (max-width: 558px) 100vw, 558px" /><br /><strong>Step 5-</strong> Click <strong>Add User or Group</strong> and add any user accounts that are used to run SQL Server services. You can get SQL Server service account from SQL Server Configuration Manager or from services.msc console.</p>
<p><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-824" src="http://techyaz.com/wp-content/uploads/2017/09/4-sql-services.jpg" alt="SQL Server Services" width="739" height="273" srcset="https://techyaz.com/wp-content/uploads/2017/09/4-sql-services.jpg 739w, https://techyaz.com/wp-content/uploads/2017/09/4-sql-services-300x111.jpg 300w" sizes="auto, (max-width: 739px) 100vw, 739px" /></p>
<p>Now add account <strong>Domain\techyaz</strong> to above policy. It would be great if you create a group and add this account to that group and then add that group to given policy so that every time you don&#8217;t need to add user account here if SQL Server service account got changed.</p>
<p><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-825" src="http://techyaz.com/wp-content/uploads/2017/09/5-local-policy.jpg" alt="" width="495" height="525" srcset="https://techyaz.com/wp-content/uploads/2017/09/5-local-policy.jpg 495w, https://techyaz.com/wp-content/uploads/2017/09/5-local-policy-283x300.jpg 283w" sizes="auto, (max-width: 495px) 100vw, 495px" /><br /><strong>Step 6-</strong> Once SQL Server service account will be added, it will look like below image. Click <strong>Apply</strong>, and then close all Local Security Policy dialog boxes.</p>
<p><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-826" src="http://techyaz.com/wp-content/uploads/2017/09/6-local-policy.jpg" alt="" width="453" height="523" srcset="https://techyaz.com/wp-content/uploads/2017/09/6-local-policy.jpg 453w, https://techyaz.com/wp-content/uploads/2017/09/6-local-policy-260x300.jpg 260w" sizes="auto, (max-width: 453px) 100vw, 453px" /><br /><strong>Step 7-</strong> <strong>Restart</strong> SQL Server services to apply this change.</p>
<p>If you need to enable this feature on Cluster environment, make sure to perform this activity on all cluster nodes. If you are running with multiple SQL Server Instances, add all required security logins/group to this policy.</p>
<h3>How to Check If instant file initialization is Enabled Or Not?</h3>
<p>Now if you think <strong>how to know Instant File Initialization is enabled on your SQL Server</strong> Instance then here is the answer. You should check SQL Server logs to get the details about Instant File Initialization. When SQL Server service starts, database engine checks all details of SQL Server configurations and capture them into log file. You can see my error log file after restarting SQL Server service. Instant File Initialization is showing as enabled on this server.</p>
<pre class="brush: sql; title: ; notranslate" title=""><span style="color: #0000ff;"><strong>2017-06-16 11:16:49.15 Server Database Instant File Initialization: enabled. </strong></span><span style="color: #0000ff;"><strong>For security and performance considerations see the topic ‘Database Instant File Initialization’ in SQL Server Books Online. This </strong></span><span style="color: #0000ff;"><strong>is an informational message only. No user action is required.
</strong></span></pre>
<p><img loading="lazy" decoding="async" class="aligncenter size-large wp-image-827" src="http://techyaz.com/wp-content/uploads/2017/09/7-Instant-file-initilization-enabled-log-1024x238.jpg" alt="instant file initialization in sql server log file" width="1024" height="238" srcset="https://techyaz.com/wp-content/uploads/2017/09/7-Instant-file-initilization-enabled-log-1024x238.jpg 1024w, https://techyaz.com/wp-content/uploads/2017/09/7-Instant-file-initilization-enabled-log-300x70.jpg 300w, https://techyaz.com/wp-content/uploads/2017/09/7-Instant-file-initilization-enabled-log-768x179.jpg 768w, https://techyaz.com/wp-content/uploads/2017/09/7-Instant-file-initilization-enabled-log.jpg 1091w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></p>
<h3><span style="color: #000080;">Advantages</span></h3>
<p>Instant File Initialization improves performance of multiple database activities where large size of data file creation or Autogrow operation will perform. This can vastly speed up these operations as zero-initialization can take a long time for large files. Below are the operations that can take advantage from this feature.</p>
<ul>
<li>Data Load/Import</li>
<li>New Database Creation</li>
<li>Database Restore</li>
<li>Autogrow Operation</li>
<li>Data file size Increase</li>
<li>Backup file Creation</li>
</ul>
<h3><span style="color: #000080;">Limitations</span></h3>
<p>This feature will not work if:</p>
<ul>
<li>Your file is a log file.</li>
<li>The account has not the required privilege.</li>
<li>It is a sparse file &#8211; Database Snapshots.</li>
<li>Transparent Data Encryption (TDE) is enabled.</li>
<li>Trace flag 1806 is enabled to disable instant file initialization.</li>
</ul>
<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><em><strong>Read More: </strong></em></p>
<ul>
<li><strong><a href="https://techyaz.com/sql-server/troubleshooting/fix-sql-server-error-5009/" target="_blank" rel="noopener">SQL Server Error 5009: One or more files listed in the statement could not be found or could not be initialized</a></strong></li>
<li><strong><a href="https://techyaz.com/sql-server/troubleshooting/fix-msg-5144-and-5145-for-long-or-failed-autogrow/" target="_blank" rel="noopener">Fix SQL Server Msg 5144 and 5145 for long or failed autogrow of data and log files</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>
</ul>


<p></p>
<p>The post <a href="https://techyaz.com/sql-server/sql-server-administration/instant-file-initialization-enable-on-sql-server-instance/">What is Instant File Initialization and How to enable it on SQL Server Instance?</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/instant-file-initialization-enable-on-sql-server-instance/feed/</wfw:commentRss>
			<slash:comments>0</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 loading="lazy" 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="auto, (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 loading="lazy" 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="auto, (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 loading="lazy" 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="auto, (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>
		<item>
		<title>Understanding SQL Server Transaction Log File Architecture</title>
		<link>https://techyaz.com/sql-server/understanding-transaction-log-architecture/</link>
					<comments>https://techyaz.com/sql-server/understanding-transaction-log-architecture/#respond</comments>
		
		<dc:creator><![CDATA[Manvendra Deo Singh]]></dc:creator>
		<pubDate>Mon, 24 Jul 2017 12:35:30 +0000</pubDate>
				<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[log_files]]></category>
		<category><![CDATA[SQL_Server_Architecture]]></category>
		<guid isPermaLink="false">http://techyaz.com/?p=265</guid>

					<description><![CDATA[<p>Today, i will talk about SQL Server Transaction Log File Architecture. As we know, every database must have at least one transaction log file (Tlog file) that captures everything happens on database to maintain data integrity of the database. Logically,&#46;&#46;&#46;</p>
<p>The post <a href="https://techyaz.com/sql-server/understanding-transaction-log-architecture/">Understanding SQL Server Transaction Log File Architecture</a> appeared first on <a href="https://techyaz.com">Techyaz.com</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>Today, i will talk about SQL Server Transaction Log File Architecture. As we know, every database must have at least one transaction log file (Tlog file) that captures everything happens on database to maintain data integrity of the database. Logically, SQL Server transaction log file is a series of log records whereas physically these log records stored in this transaction log file that are placed on OS drive.  I will discuss about the SQL Server transaction log file architecture in this article. Let us start with logical architecture of Tlog file followed by the physical architecture.</p>
<p><em><strong><span style="color: #800000;">Related Articles:</span></strong></em></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">What is the best value for database file autogrowth?</a></strong></li>
<li><strong><a href="https://techyaz.com/sql-server/what-should-be-the-best-value-for-fill-factor-in-sql-server/" target="_blank" rel="noopener">What is the Suitable Value for Fill Factor?</a></strong></li>
</ul>
<h3><span style="color: #000080;">Logical Architecture</span></h3>
<p>To understand SQL Server Transaction Log File Architecture, we need to start with basics. As we know transaction log file is mandatory database file for a database. Every database must have at least one transaction log file. SQL Server uses transaction log file to capture log records that guarantee the data integrity of the database and for data recovery.</p>
<p>Logically, SQL Server transaction log is a string of log records. Each log record is identified by a <strong>log sequence number (LSN)</strong>. Each new log record is written with the incremental LSN that means a new log record will be assigned a LSN that is higher than the LSN of the record before it. Log records are stored in a serial sequence as they are created.</p>
<h3><span style="color: #000080;"><strong>Operations that recorded in the Transaction Log File</strong></span></h3>
<p>There are many types of operations recorded in Tlog files. These operations include:</p>
<ol>
<li>The start and end of each transaction.</li>
<li>Every data modification (insert, update, or delete). This includes changes by system stored procedures or data definition language (DDL) statements to any table, including system tables.</li>
<li>Every extent and page allocation or deallocation.</li>
<li>Creating or dropping a table or index.</li>
<li>Rollback operations. Each transaction reserves space on the transaction log to make sure that enough log space exists to support a rollback that is caused by either an explicit rollback statement or if an error is encountered. This reserved space is freed when the transaction is completed.</li>
</ol>
<p>The section of the log file from the first log record that must be present for a successful database-wide rollback to the last-written log record is called the active part of the log, or the active log. This is the section of the log required to do a full recovery of the database. You can not truncate any part of active log.<strong> </strong></p>
<h3><span style="color: #000080;">Physical Architecture</span></h3>
<p>As we know, a series of log records stores in transaction log file. These log files store physically on OS drive/disk along with <a href="https://techyaz.com/sql-server/understanding-sql-server-data-files-pages-extents/" target="_blank" rel="noopener">SQL Server data files.</a> Each transaction log file internally divided into a number of <strong>virtual log files</strong>. <a href="https://techyaz.com/sql-server/get-total-virtual-log-files/" target="_blank" rel="noopener"><strong>Virtual log files</strong></a> have no fixed size, and there is no fixed number of virtual log files for a physical log file.  The size or number of virtual log files cannot be configured by administrators. You can get <a href="https://techyaz.com/sql-server/get-total-virtual-log-files/" target="_blank" rel="noopener">total count of virtual log files</a> or vlfs in a SQL Server database log file/s in attached link. Here, i have explained in detail about how to track virtual log files.</p>
<p>The Database Engine chooses the size of the virtual log files dynamically while it 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.</p>
<p>If we define small Tlog file size along with small growth increment then it will cause performance issue to your system because whenever log file needs more room, it will increase log file size frequently due to small size of growth increment so it will create lot of virtual log files as well. This will affect performance of backup and restore operation along with database startup performance.</p>
<p><strong>Microsoft recommends</strong> that we should assign log files a size value close to the final size required, and also have a relatively large growth increment value.</p>
<h3><span style="color: #000080;">How Transactions Log File works?</span></h3>
<p>The transaction log is a wrap-around file. Let us demonstrate it using a scenario given in <a href="https://msdn.microsoft.com/en-us/library/ms345419.aspx">Microsoft Book Online.</a></p>
<p>Consider a database with one physical log file divided into four virtual log files. When the database is created, the logical log file begins at the start of the physical log file. New log records are added at the end of the logical log and expand toward the end of the physical log. Log truncation frees any virtual logs whose records all appear in front of the minimum recovery log sequence number (MinLSN). The MinLSN is the log sequence number of the oldest log record that is required for a successful database-wide rollback.</p>
<p>When the end of the logical log reaches the end of the physical log file, the new log records wrap around to the start of the physical log file.</p>
<p>This cycle repeats endlessly, as long as the end of the logical log never reaches the beginning of the logical log. If the old log records are truncated frequently enough to always leave sufficient room for all the new log records created through the next <a href="https://techyaz.com/sql-server/checkpoint/" target="_blank" rel="noopener">checkpoint</a>, the log never fills. However, if the end of the logical log does reach the start of the logical log, one of two things occurs:</p>
<ol>
<li>If the FILEGROWTH setting is enabled for the log and space is available on the disk, the file is extended by the amount specified in growth_increment and the new log records are added to the extension.</li>
<li>If the FILEGROWTH setting is not enabled, or the disk that is holding the log file has less free space than the amount specified in growth_increment, a 9002 error is generated.</li>
</ol>
<p>If the log contains multiple physical log files, the logical log will move through all the physical log files before it wraps back to the start of the first physical tlog file.</p>
<p>You can follow attached link to understand <a href="https://techyaz.com/sql-server/understanding-sql-server-data-files-pages-extents/" target="_blank" rel="noopener">SQL Server data files, Pages &amp; Extents.</a>  I hope you like this article. Here i have described SQL Server Transaction Log File Architecture that will help you to understand SQL Server database system. 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><em><strong><span style="color: #800000;">Read More:</span></strong></em></p>
<ul>
<li><strong><a href="https://techyaz.com/sql-server/avoid-database-shrink-operation/" target="_blank" rel="noopener">Understanding Database Shrink Operation and Why Should We Avoid It?</a></strong></li>
<li><strong><a href="https://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></strong></li>
<li><strong><a href="https://techyaz.com/sql-server/troubleshooting/fix-msg-5144-and-5145-for-long-or-failed-autogrow/" target="_blank" rel="noopener">Fix SQl Server Error 5144 and 5145 for long and failed Autogrow of data and log file</a></strong></li>
</ul>
<p>The post <a href="https://techyaz.com/sql-server/understanding-transaction-log-architecture/">Understanding SQL Server Transaction Log File Architecture</a> appeared first on <a href="https://techyaz.com">Techyaz.com</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://techyaz.com/sql-server/understanding-transaction-log-architecture/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Understanding SQL Server Data Files, Pages &#038; Extents</title>
		<link>https://techyaz.com/sql-server/understanding-sql-server-data-files-pages-extents/</link>
					<comments>https://techyaz.com/sql-server/understanding-sql-server-data-files-pages-extents/#comments</comments>
		
		<dc:creator><![CDATA[Manvendra Deo Singh]]></dc:creator>
		<pubDate>Fri, 21 Jul 2017 19:28:22 +0000</pubDate>
				<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[data_files]]></category>
		<category><![CDATA[extent]]></category>
		<category><![CDATA[page]]></category>
		<category><![CDATA[SQL_Server_Architecture]]></category>
		<guid isPermaLink="false">http://techyaz.com/?p=256</guid>

					<description><![CDATA[<p>SQL Server data files, pages &#38; extents are very much related to each other. These are architectural terms which are used to store data physically inside the database. First let&#8217;s start with data files then we will understand how data&#46;&#46;&#46;</p>
<p>The post <a href="https://techyaz.com/sql-server/understanding-sql-server-data-files-pages-extents/">Understanding SQL Server Data Files, Pages &#038; Extents</a> appeared first on <a href="https://techyaz.com">Techyaz.com</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>SQL Server data files, pages &amp; extents are very much related to each other. These are architectural terms which are used to store data physically inside the database. First let&#8217;s start with data files then we will understand how data files are related to pages and then to extents.</p>
<p><span style="color: #800000;"><em><strong>Related Articles:</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">What is 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>
<h3><span style="color: #000080;"><strong>SQL Server Data Files </strong></span></h3>
<p>When we create any SQL Server database, few operating system files are created and placed in to their respective directories. These files are known as database files. SQL Server databases have three types of files to handle data and log separately.</p>
<ul>
<li>Primary data file</li>
<li>Secondary data files</li>
<li><a href="https://techyaz.com/sql-server/understanding-transaction-log-architecture/" target="_blank" rel="noopener">Log files</a></li>
</ul>
<p>Every database has only one primary data file but none to multiple secondary data files whereas same database has minimum one log file and can have multiple log files depending on the requirements. <a href="https://techyaz.com/sql-server/understanding-transaction-log-architecture/" target="_blank" rel="noopener">Log files</a> hold all the log information that is used to recover the database whereas all data files keeps or stores the actual data of the database.</p>
<p>The recommended file extension for primary, secondary data file and log file are .mdf, .ndf and .ldf respectively although it is not mandatory to keep same extension names but it helps you identify the different kinds of files and their use.</p>
<p>Each database file has two names one is logical file name another one is physical file name. The logical file name is the name used to refer to the physical file in all Transact-SQL statements whereas physical file name is the name that appear on the OS directory path.</p>
<h3><span style="color: #000080;"><strong>Pages &amp; Extents</strong></span></h3>
<p>We read in above section that every database has data files to store actual data. Data stores inside these data files in form of Pages so Page is the fundamental unit of data storage in SQL Server but Log files do not store any data, they contain a series of log records so log files do not have any pages.</p>
<p>The disk space allocated to a data file (.mdf or .ndf) in a database is logically divided into pages numbered contiguously from 0 to n. Pages in a SQL Server data file are numbered sequentially, starting with zero (0) for the first page in the file. Each file in a database has a unique file ID number. To uniquely identify a page in a database, both the file ID and the page number are required.</p>
<p><img loading="lazy" decoding="async" class="aligncenter size-large wp-image-258" src="http://techyaz.com/wp-content/uploads/2017/07/Page-Extent-1024x576.jpg" alt="SQL Server page extent data files" width="1024" height="576" srcset="https://techyaz.com/wp-content/uploads/2017/07/Page-Extent-1024x576.jpg 1024w, https://techyaz.com/wp-content/uploads/2017/07/Page-Extent-300x169.jpg 300w, https://techyaz.com/wp-content/uploads/2017/07/Page-Extent-768x432.jpg 768w, https://techyaz.com/wp-content/uploads/2017/07/Page-Extent.jpg 1280w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></p>
<p>The size of page is 8 KB. Each page begins with 96-byte header as shown in above image that is used to store system information about the page. This information includes the page number, page type, the amount of free space on the page, and the allocation unit ID of the object that owns the page.</p>
<p>Data rows are put on the page serially, starting immediately after the header. A row offset table starts at the end of the page, and each row offset table contains one entry for each row on the page. Each entry records how far the first byte of the row is from the start of the page. The entries in the row offset table are in reverse sequence from the sequence of the rows on the page.</p>
<p>Extents are a collection of eight physically contiguous pages and are used to efficiently manage the pages. All pages are stored in extents.</p>
<p>The first page in each file is a file header page that contains information about the attributes of the file. Several of the other pages at the start of the file also contain system information, such as allocation maps. Below are the list of page types used in the data files of a SQL Server database.</p>
<ol>
<li><span style="color: #000080;"><strong>Data: </strong></span>Data Page stores data rows with all data, except large object data types like text, ntext, image, nvarchar(max), varchar(max), varbinary(max), and xml data, when text in row is set to ON.</li>
<li><span style="color: #000080;"><strong>Index:</strong> </span>Stores <a href="https://techyaz.com/sql-server/understanding-sql-server-indexes/" target="_blank" rel="noopener">Index</a> data.</li>
<li><span style="color: #000080;"><strong>Text/Image: </strong></span>Stores large object data types like text, ntext, image, nvarchar(max), varchar(max), varbinary(max), and xml data</li>
<li><span style="color: #000080;"><strong>Global Allocation Map: </strong></span>GAM pages record what extents have been allocated. Each GAM covers 64,000 extents, or almost 4 GB of data. The GAM has one bit for each extent in the interval it covers. If the bit is 1, the extent is free; if the bit is 0, the extent is allocated.</li>
<li style="text-align: left;"><span style="color: #000080;"><strong>Shared Global Allocation Map: </strong></span>SGAM pages record which extents are currently being used as mixed extents and also have at least one unused page. Each SGAM covers 64,000 extents, or almost 4 GB of data.</li>
</ol>
<p style="padding-left: 30px; text-align: left;">The SGAM has one bit for each extent in the interval it covers. If the bit is 1, the extent is being used as a mixed     extent and has a free page. If the bit is 0, the extent is not used as a mixed extent, or it is a mixed extent and all     its pages are being used.</p>
<ol style="text-align: left;" start="6">
<li><span style="color: #000080;"><strong>Page Free Space: </strong></span>Page Free Space (PFS) pages record the allocation status of each page, whether an individual page has been allocated, and the amount of free space on each page. The PFS has one byte for each page, recording whether the page is allocated, and if so, whether it is empty, 1 to 50 percent full, 51 to 80 percent full, 81 to 95 percent full, or 96 to 100 percent full.</li>
</ol>
<p style="padding-left: 30px; text-align: left;">After an extent has been allocated to an object, the Database Engine uses the PFS pages to record which pages     in the extent are allocated or free. This information is used when the Database Engine has to allocate a new           page.</p>
<ol style="text-align: left;" start="7">
<li><span style="color: #000080;"><strong>Index Allocation Map</strong>:</span> Information about extents used by a table or index per allocation unit. When the SQL Server Database Engine has to insert a new row and no space is available in the current page, it uses the IAM and PFS pages to find a page to allocate, or, for a heap or a Text/Image page, a page with sufficient space to hold the row. The Database Engine uses the IAM pages to find the extents allocated to the allocation unit.</li>
<li><span style="color: #000080;"><strong>Bulk Changed Map: </strong></span>Information about extents modified by bulk operations since the last BACKUP LOG statement per allocation unit. This tracks the extents that have been modified by bulk logged operations since the last BACKUP LOG statement.</li>
</ol>
<p style="text-align: left; padding-left: 30px;">If the bit for an extent is 1, the extent has been modified by a bulk logged operation after the last BACKUP LOG   statement. If the bit is 0, the extent has not been modified by bulk logged operations.</p>
<p style="text-align: left; padding-left: 30px;">Although BCM pages appear in all databases, they are only relevant when the database is using the bulk-logged recovery model. In this recovery model, when a BACKUP LOG is performed, the backup process scans the             BCMs for extents that have been modified. It then includes those extents in the log backup. This lets the bulk       logged operations be recovered if the database is restored from a database backup and a sequence of   transaction  log backups.</p>
<p style="text-align: left; padding-left: 30px;"> BCM pages are not relevant in a database that is using the simple recovery model, because no bulk logged  operations are logged. They are not relevant in a database that is using the full recovery model, because that  recovery model treats bulk logged operations as fully logged operations.</p>
<ol style="text-align: left;" start="9">
<li><strong><span style="color: #000080;">Differential Changed Map:</span> </strong>Information about extents that have changed since the last <a href="https://techyaz.com/sql-server/understanding-sql-server-backups/" target="_blank" rel="noopener">BACKUP DATABASE</a> statement per allocation unit. This tracks the extents that have changed since the last BACKUP DATABASE statement.</li>
</ol>
<p style="text-align: left; padding-left: 30px;">  If the bit for an extent is 1, the extent has been modified since the last BACKUP DATABASE statement. If the bit is 0, the extent has not been modified.</p>
<p style="text-align: left; padding-left: 30px;">Differential backups read just the DCM pages to determine which extents have been modified. This greatly reduces the number of pages that a differential backup must scan. The length of time that a differential backup runs is proportional to the number of extents modified since the last BACKUP DATABASE statement and not the overall size of the database.</p>
<h3><span style="color: #000080;"><strong>Sequence of Pages in Data file</strong></span></h3>
<p>A PFS page is the first page after the file header page in a data file (page number 1). This is followed by a GAM page (page number 2), and then an SGAM page (page 3). There is a PFS page approximately 8,000 pages in size after the first PFS page. There is another GAM page 64,000 extents after the first GAM page on page 2, and another SGAM page 64,000 extents after the first SGAM page on page 3. The DCM and BCM pages are located behind the GAM and SGAM pages in a physical file and interval between DCM pages and BCM pages is the same as the interval between GAM and SGAM page, 64,000 extents.</p>
<p>I hope this article helps you to understand data files, pages and extents. The source of this article is <a href="https://msdn.microsoft.com/en-us/library/cc280361.aspx">MSDN Book Online</a>.  If you like this article, you can follow us on our <strong><a href="https://www.facebook.com/Techyaz/" target="_blank" rel="noopener">facebook page</a></strong> and on <strong><a href="https://twitter.com/Tech_yaz" target="_blank" rel="noopener">Twitter</a></strong> handle to get latest updates.</p>
<p>The post <a href="https://techyaz.com/sql-server/understanding-sql-server-data-files-pages-extents/">Understanding SQL Server Data Files, Pages &#038; Extents</a> appeared first on <a href="https://techyaz.com">Techyaz.com</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://techyaz.com/sql-server/understanding-sql-server-data-files-pages-extents/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
			</item>
	</channel>
</rss>
