<?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>index rebuild - Techyaz.com</title>
	<atom:link href="https://techyaz.com/tag/index-rebuild/feed/" rel="self" type="application/rss+xml" />
	<link></link>
	<description>Tips, Tutorials and How-to Topics</description>
	<lastBuildDate>Fri, 01 Jun 2018 12:35:28 +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>index rebuild - Techyaz.com</title>
	<link></link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>How to Use Resumable Online Index Rebuild Operation in SQL Server?</title>
		<link>https://techyaz.com/sql-server/indexes/use-resumable-online-index-rebuild-operation-sql-server/</link>
					<comments>https://techyaz.com/sql-server/indexes/use-resumable-online-index-rebuild-operation-sql-server/#respond</comments>
		
		<dc:creator><![CDATA[Manvendra Deo Singh]]></dc:creator>
		<pubDate>Wed, 03 Jan 2018 15:25:54 +0000</pubDate>
				<category><![CDATA[Indexes]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[Index]]></category>
		<category><![CDATA[index rebuild]]></category>
		<category><![CDATA[New features in SQL Server 2017]]></category>
		<category><![CDATA[Resumable Online Index Rebuild]]></category>
		<category><![CDATA[SQL Server 2017]]></category>
		<category><![CDATA[SQL Server Indexes]]></category>
		<guid isPermaLink="false">http://techyaz.com/?p=1431</guid>

					<description><![CDATA[<p>Resumable Online Index Rebuild is a new feature introduced in SQL Server 2017. Index Rebuild operation is very expensive task that takes lot of system resources and log spaces during execution. Sometimes, we need to cancel index rebuild operation in&#46;&#46;&#46;</p>
<p>The post <a href="https://techyaz.com/sql-server/indexes/use-resumable-online-index-rebuild-operation-sql-server/">How to Use Resumable Online Index Rebuild Operation in SQL Server?</a> appeared first on <a href="https://techyaz.com">Techyaz.com</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>Resumable Online Index Rebuild is a new feature introduced in SQL Server 2017. <strong><a href="http://techyaz.com/sql-server/difference-index-rebuild-reorganize/" target="_blank" rel="noopener">Index Rebuild operation</a> </strong>is very expensive task that takes lot of system resources and log spaces during execution. Sometimes, we need to cancel index rebuild operation in middle of its execution to reclaim the space as well as system resources to avoid any performance issue, space issue or blocking issues. In previous versions of SQL Server, we rerun index rebuild operation again if we cancel it during its execution to make sure the database maintenance activity should be done. Re-execution of this job will start rebuilding indexes again from scratch that will take lot of time and resources again. Microsoft has given a solution named Resumable Index Rebuild to overcome of this scenario. Resumable Online Index Rebuild option is an extension of feature Online Index Operation in SQL Server. Read below article if you want to understand the disk and performance impact of using online index rebuild operation.</p>
<ul>
<li><strong><a href="http://techyaz.com/sql-server/performing-online-index-rebuild-operation/" target="_blank" rel="noopener">What would be Disk and Performance Impact if we rebuild indexes using ONLINE option?</a></strong></li>
</ul>
<h3><span style="color: #333399;">Resumable Online Index Rebuild</span></h3>
<p>This feature allows us to pause index rebuild operation during its execution at any point and resume it later from the point it was paused. You can use this feature in case you get any higher priority tasks or your server is running out of disk space or facing any performance issue. In addition, this feature rebuilds indexes using only a small amount of log space.</p>
<p>This feature allows us to resume an index rebuild operation after an index rebuild failure, such as after a database failover or after running out of disk space. We can also pause an ongoing index rebuild operation and resume it later. Resumable Online Index Rebuild allows us to rebuild large indexes without using a lot of log space.</p>
<p><em><span style="color: #800000;"><strong>Read More</strong></span></em></p>
<ul>
<li><strong><a href="http://techyaz.com/sql-server/sql-server-interview-questions-answers-indexes/" target="_blank" rel="noopener">SQL Server Interview Questions &amp; Answers on Indexes</a></strong></li>
<li><strong><a href="http://techyaz.com/sql-server/what-should-be-the-best-value-for-fill-factor-in-sql-server/" target="_blank" rel="noopener">What should be Best Value for fill factor in SQL Server?</a></strong></li>
<li><strong><a href="http://techyaz.com/sql-server/how-to-avoid-page-split-in-sql-server/" target="_blank" rel="noopener">How to Avoid Page Split in SQL Server?</a></strong></li>
</ul>
<h3><span style="color: #333399;">Points to Consider</span></h3>
<p>Below are the points you must keep in mind if you are choosing resumable online index rebuild operation.</p>
<ol>
<li>When an index operation is paused, both the original index and the the newly created one require disk space and need to be updated during DML operations.</li>
<li>Enables truncation of transaction logs during an index rebuild operation (this operation cannot be performed for a regular online index operation).</li>
<li>Resumable Online Index Rebuild feature can be used only with<strong> <a href="http://techyaz.com/sql-server/performing-online-index-rebuild-operation/" target="_blank" rel="noopener">Online Index Rebuild operation</a></strong>. You cannot use it for offline index rebuild operation.</li>
<li>We cannot rebuild an index that is disabled.</li>
<li>We cannot use ALL option to rebuild existing indexes.</li>
<li>Resumable Index Rebuild operation cannot be used to rebuild an existing index that has either computed column or timestamp column as part of the index key.</li>
<li>We cannot use SORT_IN_TEMPDB=ON option if we choose to use resumable index rebuild option.</li>
</ol>
<p><img fetchpriority="high" decoding="async" class="aligncenter wp-image-1433 size-full" src="http://techyaz.com/wp-content/uploads/2018/01/Resumable-Online-Index-Rebuild.png" alt="Resumable Online Index Rebuild" width="560" height="315" srcset="https://techyaz.com/wp-content/uploads/2018/01/Resumable-Online-Index-Rebuild.png 560w, https://techyaz.com/wp-content/uploads/2018/01/Resumable-Online-Index-Rebuild-300x169.png 300w" sizes="(max-width: 560px) 100vw, 560px" /></p>
<p>&nbsp;</p>
<h3><span style="color: #333399;">How to use Resumable Online Index Rebuild?</span></h3>
<p>I have given multiple examples to demonstrate the different use cases of resumable online index rebuild operation in this section. If we want to use the resumable index rebuild functionality, we need to execute the online index rebuild with <strong>RESUMABLE</strong> keyword because Resumable index rebuild supports only during online index rebuild, so we must specify <strong>ONLINE = ON</strong> along with <strong>RESUMABLE = ON</strong> option. You cannot use this feature until you mention <strong>RESUMABLE = ON </strong>in your code because RESUMABLE=OFF is the default value. Run below command to rebuild index online as resumable option.</p>
<pre><strong><span style="color: #0000ff;">ALTER INDEX INDEX_Name on Table_Name
REBUILD WITH (ONLINE=ON, RESUMABLE=ON) ;
</span></strong></pre>
<p>We can also specify MAXDOP settings during online index rebuild as resumable option to use parallelism. Execute an online index rebuild as resumable operation with <strong>MAXDOP=1</strong> by running below command.</p>
<pre><strong><span style="color: #0000ff;">ALTER INDEX INDEX_Name on Table_Name 
REBUILD WITH (ONLINE=ON, MAXDOP=1, RESUMABLE=ON) ;
</span></strong></pre>
<p>We can also control execution or processing time of resumable online index rebuild by specifying <strong>MAX_DURATION</strong> option. It specifies the number of minutes that the resumable online index operation will be executed, before being paused. Execute an online index rebuild as resumable operation with MAX_DURATION set to 30 minutes.</p>
<pre><strong><span style="color: #0000ff;">ALTER INDEX INDEX_Name on Table_Name 
REBUILD WITH (ONLINE=ON, RESUMABLE=ON, MAX_DURATION=30) ;</span></strong></pre>
<p>Next, we will discuss about pausing these index rebuild operations that are running as resumable option in next section.</p>
<h3><span style="color: #333399;">Pause Online Index Rebuild running with Resumable Option</span></h3>
<p>If you want to manually pause a running resumable online index rebuild then you just need to use PAUSE clause in above ALTER INDEX statements. Run below command to pause a resumable index rebuild operation.</p>
<pre><strong><span style="color: #0000ff;">ALTER INDEX INDEX_Name on Table_Name PAUSE ;
</span></strong></pre>
<p>Now we will discuss about how to resume a paused online index rebuild operation in next section.</p>
<h3><span style="color: #333399;">Resume an Online Index Rebuild running with Resumable Option</span></h3>
<p>As I have mentioned above, you can pause online index rebuild due to any reason. Let’s say suppose you pause it because it is taking lot of time to complete and consuming lot of system resources then you can either resume it later when system has enough resource to run this operation or you can resume it specifying a new value for MAXDOP setting that will allow this operation to use parallelism to finish this task.</p>
<p>Suppose you want to resume an online index rebuild for an index rebuild that was executed as resumable operation specifying a new value for MAXDOP set to 8.</p>
<pre><strong><span style="color: #0000ff;">ALTER INDEX INDEX_Name on Table_Name </span></strong>
<strong><span style="color: #0000ff;">RESUME WITH (MAXDOP=8) ;
</span></strong></pre>
<p>If you want to resume an online index rebuild for an index rebuild that was executed as resumable operation with the same values then you can remove the MAXDOP options from above command and execute the simple command given below.</p>
<pre><strong><span style="color: #0000ff;">ALTER INDEX INDEX_Name on Table_Name RESUME;
</span></strong></pre>
<p>You can also resume an online index rebuild operation for an index rebuild that was executed as resumable with different parameters like you can set MAXDOP to 2, set the execution time for the index being running as resumable to 60 minutes and in case of an index being blocked on the lock wait 10 minutes and after that kill all blockers. Run below command to rebuild your indexes with above criteria.</p>
<pre><strong><span style="color: #0000ff;">ALTER INDEX INDEX_Name on Table_Name
RESUME WITH (MAXDOP=2, MAX_DURATION= 60 MINUTES,
WAIT_AT_LOW_PRIORITY (MAX_DURATION=10, ABORT_AFTER_WAIT=BLOCKERS)) ;
</span></strong></pre>
<p>You can test it in your lower life cycle with multiple options and keywords to get in depth knowledge about this feature.</p>
<h3><span style="color: #333399;">Abort a Resumable Index Rebuild operation</span></h3>
<p>We can also abort resumable index rebuild operation which is running or paused by executing below T-SQL statement.</p>
<pre><strong><span style="color: #0000ff;">ALTER INDEX INDEX_Name on Table_Name ABORT ;
</span></strong></pre>
<p>Once you will run above command, your index rebuild operation will be aborted.</p>
<h3><span style="color: #333399;">Monitor Resumable Index Rebuild Operation</span></h3>
<p>Microsoft has given a system view<strong> sys.index_resumable_operations</strong> that monitors and checks the current execution status for resumable Index rebuild. You can also get the progress details in percentage of resumable index rebuild operation using this system view.</p>
<p>There is a column named <strong>state</strong> in this system view that will let us know the state of the resumable index rebuild operation whether it is paused or still running. You can query this system view to see all the resumable index rebuild operations that are currently paused or running.</p>
<p>Run below command to list all resumable index rebuild operations that are in the PAUSE state. State column value zero means online index rebuild is running and value 1 means they are paused. You can also check the percent completion of all resumable index rebuild operations from column <strong>PERCENT_COMPLETE</strong> from the output received by below command.</p>
<pre><strong><span style="color: #0000ff;">SELECT * FROM  sys.index_resumable_operations WHERE STATE = 1;
</span></strong></pre>
<p><em><span style="color: #800000;"><strong>Related Articles</strong></span></em></p>
<ul>
<li><strong><a href="http://techyaz.com/sql-server/performing-online-index-rebuild-operation/" target="_blank" rel="noopener">Performing Online Index Rebuild Operation</a></strong></li>
<li><strong><a href="http://techyaz.com/sql-server/understanding-sql-server-indexes/" target="_blank" rel="noopener">Understanding SQL Server Indexes and difference between Clustered and Nonclustered Indexes</a></strong></li>
<li><strong><a href="http://techyaz.com/sql-server/difference-index-rebuild-reorganize/" target="_blank" rel="noopener">Difference between Index Rebuild and Index Reorganize Operation </a></strong></li>
</ul>
<p>I hope you like this article. Please follow our <a href="https://www.facebook.com/Techyaz/">Facebook</a> page and <a href="https://twitter.com/Tech_yaz">Twitter </a>handle to get latest updates.</p>
<p>The post <a href="https://techyaz.com/sql-server/indexes/use-resumable-online-index-rebuild-operation-sql-server/">How to Use Resumable Online Index Rebuild Operation 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/indexes/use-resumable-online-index-rebuild-operation-sql-server/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Disk and Performance Impact of Online Index Rebuild Operation</title>
		<link>https://techyaz.com/sql-server/indexes/performing-online-index-rebuild-operation/</link>
					<comments>https://techyaz.com/sql-server/indexes/performing-online-index-rebuild-operation/#respond</comments>
		
		<dc:creator><![CDATA[Manvendra Deo Singh]]></dc:creator>
		<pubDate>Fri, 29 Dec 2017 12:18:51 +0000</pubDate>
				<category><![CDATA[Indexes]]></category>
		<category><![CDATA[Performance Tuning]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQL Server Administration]]></category>
		<category><![CDATA[T-SQL]]></category>
		<category><![CDATA[Clustered Index]]></category>
		<category><![CDATA[Index]]></category>
		<category><![CDATA[index rebuild]]></category>
		<category><![CDATA[Nonclustered Index]]></category>
		<category><![CDATA[SQL Server Indexes]]></category>
		<guid isPermaLink="false">http://techyaz.com/?p=1421</guid>

					<description><![CDATA[<p>Here, we are going to talk about disk and performance Impact of online Index rebuild operation. As we know index rebuild is offline operation due to which indexes become inaccessible. Here, I will describe about SQL Server rebuild index online&#46;&#46;&#46;</p>
<p>The post <a href="https://techyaz.com/sql-server/indexes/performing-online-index-rebuild-operation/">Disk and Performance Impact of Online Index Rebuild Operation</a> appeared first on <a href="https://techyaz.com">Techyaz.com</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>Here, we are going to talk about disk and performance Impact of online Index rebuild operation. As we know index rebuild is offline operation due to which indexes become inaccessible. Here, I will describe about SQL Server rebuild index online that will keep SQL Server indexes accessible. I hope you are aware about the<strong> <a href="http://techyaz.com/sql-server/difference-index-rebuild-reorganize/" target="_blank" rel="noopener">difference between Index rebuild and Index reorganize operation</a>.</strong> If you are not aware please have a look at attached article. Index Reorganize is already an online operation whereas Index rebuild can be done using offline as well as online method. Performing online index operations include index creation, index rebuild and drop indexes. I will describe online rebuild index operation and its impact on disk and performance in this article and same concept will be applied to online index creation and online indexe drop as well.</p>
<p>There is new feature called <em>Resumable Online Index Rebuild</em> introduced in SQL Server 2017 that is an extension of online index rebuild operation. Learn about<strong> <a href="http://techyaz.com/sql-server/use-resumable-online-index-rebuild-operation-sql-server/" target="_blank" rel="noopener">Resumable Online Index Rebuild</a></strong> operation in SQL Server 2017 in attached article.</p>
<p><em><span style="color: #800000;"><strong>Read More:</strong></span></em></p>
<ul>
<li><strong><a href="http://techyaz.com/sql-server/what-should-be-the-best-value-for-fill-factor-in-sql-server/" target="_blank" rel="noopener">What should be best value for fill factor in SQL Server?</a></strong></li>
<li><strong><a href="http://techyaz.com/sql-server/how-to-avoid-page-split-in-sql-server/" target="_blank" rel="noopener">How to Avoid Page Split in SQL Server?</a></strong></li>
<li><strong><a href="http://techyaz.com/sql-server/use-resumable-online-index-rebuild-operation-sql-server/" target="_blank" rel="noopener">How to use Resumable Online Rebuild Operation?</a></strong></li>
</ul>
<h3><span style="color: #333399;">ONLINE Index Rebuild Operation</span></h3>
<p>Rebuilding an index drops and re-creates the index. Indexes becomes unavailable during this exercise that causes an outage for that object. Microsoft has given a solution to avoid inaccessibility of the object during index rebuild operation. We can specify ONLINE keyword value as ON in CREATE INDEX or ALTER INDEX to rebuild indexes online.</p>
<p><img decoding="async" class="size-full wp-image-1423 alignleft" src="http://techyaz.com/wp-content/uploads/2017/12/Perform-Online-Index-Operations.png" alt="Online index operation" width="560" height="315" srcset="https://techyaz.com/wp-content/uploads/2017/12/Perform-Online-Index-Operations.png 560w, https://techyaz.com/wp-content/uploads/2017/12/Perform-Online-Index-Operations-300x169.png 300w" sizes="(max-width: 560px) 100vw, 560px" /></p>
<p>When you are rebuilding an index and the ONLINE option is set to ON, the underlying objects, the tables and associated indexes, are available for queries and data modification. Row versioning is used to allow for transactional consistency. SQL Server reindex ONLINE option does not work if your table has BLOB data types or index is an XML index or Spatial index.</p>
<p>I have given the list of T-SQL statements that will rebuild indexes ONLINE on your table. You just need to change the index name, table name and column name from below statements.</p>
<p>Below SQL code will rebuild the clustered index on column <strong>EMPID</strong> on the table <strong>dbo.Salary</strong>. As we are rebuilding this cluster index using dropping and recreating the cluster indexes so existing index will be dropped in the process, but it will be available during the operation because the ONLINE option is specified.</p>
<pre class="brush:sql;"><strong><span style="color: #0000ff;">CREATE CLUSTERED INDEX CI_Salary_EMPID ON dbo.Salary(EMPID)
WITH(DROP_EXISTING = ON, ONLINE = ON)
</span></strong></pre>
<p>We can also use ALTER INDEX statement to rebuild a specific index or all indexes on a specified table. The ONLINE syntax remains the same as the CREATE INDEX statement if you want to run this operation online.</p>
<pre class="brush:sql;"><strong><span style="color: #0000ff;">ALTER INDEX ALL ON [dbo.Salary]
REBUILD WITH(ONLINE = ON)
</span></strong></pre>
<p>Above statement will rebuild all indexes on table Salary keeping everything accessible during this operation. Now, we can also rebuild clustered index only on the dbo.Salary table. The ONLINE option is specified, which means that the table will be accessible during the rebuild operation.</p>
<pre class="brush:sql;"><strong><span style="color: #0000ff;">ALTER INDEX CI_Salary_EMPID ON dbo.salary
REBUILD WITH(ONLINE = ON)
</span></strong></pre>
<p>But if we will remove ONLINE option from above statement, then table will NOT be accessible during rebuild operation. You can run below command to validate the accessibility of your table for which you are rebuilding the indexes.</p>
<pre class="brush:sql;"><strong><span style="color: #0000ff;">ALTER INDEX CI_Salary_EMPID ON dbo.salary
REBUILD
</span></strong></pre>
<h3><span style="color: #333399;">Disk Space Considerations </span></h3>
<p>Disk space is an important consideration when you create, rebuild, or drop indexes. Inadequate disk space can degrade performance or even cause the index operation to fail. There might be other major performance impact of Online Index Rebuild operation as well. Please consider below recommendations if you are using Online index operations or during SQL Server rebuild index online.</p>
<ol>
<li>During ONLINE index rebuild and index creation, additional space is required in the data file to keep the second copy of the index. This is because SQL Server creates a snapshot of the index and once index rebuild or creation completes, second copy of this index will be removed by SQL Server.</li>
<li>Additional disk space is required for the temporary mapping index. This temporary index is used in online index operations that create, rebuild, or drop a clustered index.</li>
<li>Make sure the transaction log has been backed up and truncated before running index operations online, and that the log has sufficient space to store the projected index and user transactions.</li>
<li>Specify SORT_IN_TEMPDB option to ON for the index operation. This separates the index transactions from the concurrent user transactions. The index transactions will be stored in the tempdb transaction log, and the concurrent user transactions will be stored in the transaction log of the user database. Make sure to keep tempdb log and user database log files on separate drives to avoid any disk space issues.</li>
<li>Verify that the tempdb database and transaction log have sufficient disk space to handle the index operation. The tempdb transaction log cannot be truncated until the index operation is completed.</li>
<li>Do not run the online index operation in an explicit transaction. The log will not be truncated until the explicit transaction ends.</li>
</ol>
<h3><span style="color: #333399;">Performance Considerations</span></h3>
<p>If we think about performance impact of Online Index Rebuild operation on SQL Server then it will put more burden on your database server than offline index operations. Because both the source and target structures are maintained during the online index operation.</p>
<p>ONLINE Index operations will be slower than equivalent offline index operations because insert, update, and delete transactions is increased, potentially up to double. This could cause a decrease in performance and greater resource usage, especially CPU time, during the index operation. Online index operations are enterprise features and are fully logged operations.</p>
<p>It is recommended to use legacy way of index rebuild or index operations if your system allows a maintenance window. Remember users will be restricted to access data during the offline index operation, but the operation finishes faster and uses fewer resources.</p>
<p>If you have a system that runs 24&#215;7 then ONLINE index rebuild or creation will be a better choice but make sure to consider all points described in this article before choosing online index operations. You need to think from disk space and performance both prospect and design your system that can handle the load and sustain during peak hours.</p>
<p><em><span style="color: #800000;"><strong>Related Articles</strong></span></em></p>
<ul>
<li><strong><a href="http://techyaz.com/sql-server/sql-server-interview-questions-answers-indexes/" target="_blank" rel="noopener">SQL Server Interview Questions &amp; Answers on Indexes</a></strong></li>
<li><strong><a href="http://techyaz.com/sql-server/understanding-sql-server-indexes/" target="_blank" rel="noopener">Understanding Different types of Indexes in SQL Server</a></strong></li>
</ul>
<p>Here, I have described Disk and Performance Impact of Online Index Rebuild operation on SQL Server. 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/performing-online-index-rebuild-operation/">Disk and Performance Impact of Online Index Rebuild Operation</a> appeared first on <a href="https://techyaz.com">Techyaz.com</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://techyaz.com/sql-server/indexes/performing-online-index-rebuild-operation/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>How to Avoid Page Split in SQL Server?</title>
		<link>https://techyaz.com/sql-server/how-to-avoid-page-split-in-sql-server/</link>
					<comments>https://techyaz.com/sql-server/how-to-avoid-page-split-in-sql-server/#respond</comments>
		
		<dc:creator><![CDATA[Manvendra Deo Singh]]></dc:creator>
		<pubDate>Tue, 14 Nov 2017 12:48:59 +0000</pubDate>
				<category><![CDATA[Indexes]]></category>
		<category><![CDATA[Performance Tuning]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[fill factor]]></category>
		<category><![CDATA[index rebuild]]></category>
		<category><![CDATA[Page Split]]></category>
		<category><![CDATA[SQL Server Indexes]]></category>
		<guid isPermaLink="false">http://techyaz.com/?p=1130</guid>

					<description><![CDATA[<p>This is very interesting topic. How to Avoid Page Split in SQL Server? Let&#8217;s start with basics. Page split is a resource intensive operation and causes fragmentation that leads to poor performance in terms of increased I/O operations. We should&#46;&#46;&#46;</p>
<p>The post <a href="https://techyaz.com/sql-server/how-to-avoid-page-split-in-sql-server/">How to Avoid Page Split in SQL Server?</a> appeared first on <a href="https://techyaz.com">Techyaz.com</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>This is very interesting topic. How to Avoid Page Split in SQL Server? Let&#8217;s start with basics. Page split is a resource intensive operation and causes <a href="https://techyaz.com/sql-server/difference-index-rebuild-reorganize/" target="_blank" rel="noopener">fragmentation</a> that leads to poor performance in terms of increased I/O operations. We should take it seriously if  there are frequent page splits occur and consider to reduce its occurrences.  Here, i will explain how to check Page Split in SQL Server and how to reduce Page Split and its occurrence.</p>
<h3><span style="color: #333399;">What is Page Split?</span></h3>
<p>Whenever you update existing rows with the data that is bigger in size to save on their data page then Page Split operation occur to make space for this new update. Data from existing data page first move to new page that is added during Page Split operation and make room to accommodate new records. That is why this operation is resource intensive and create fragmentation. Page splits only occur when data changes in the database. If you are adding all your data at the end of the table then page split will not occur.</p>
<p>If your fill factor is 100 or 0, it will work in a same way. That means there is no room in leaf level page to accommodate future updates. Setting fill factor value to 0 or 100 will increase page split occurrences.</p>
<h3><span style="color: #333399;">How to Check Page Split in SQL Server?</span></h3>
<p>Here, i will explain how to check page split in SQL Server. Whenever Page split occurs, it will be logged in transaction log file as <strong>LOP_DELETE_SPLIT </strong>operation. We use <em>fn_dblog</em> function to read SQL Server transaction log file. Run below T-SQL code to see all page splits occurrence using transaction log file.</p>
<pre class="brush: sql; title: ; notranslate" title=""><strong><span style="color: #0000ff;">SELECT *
FROM
fn_dblog (NULL, NULL)
WHERE
[Operation] = N'LOP_DELETE_SPLIT'
</span></strong></pre>
<p>You can see LOP_DELETE_SPLIT is logged under operations column. That means it&#8217;s a page split operation.</p>
<p><img decoding="async" class="aligncenter size-full wp-image-1143" src="http://techyaz.com/wp-content/uploads/2017/11/LOP_DELETE_SPLIT.jpg" alt="page split using fn_dblog" width="654" height="347" srcset="https://techyaz.com/wp-content/uploads/2017/11/LOP_DELETE_SPLIT.jpg 654w, https://techyaz.com/wp-content/uploads/2017/11/LOP_DELETE_SPLIT-300x159.jpg 300w" sizes="(max-width: 654px) 100vw, 654px" /></p>
<p><a href="https://www.sqlskills.com/blogs/paul/tracking-page-splits-using-the-transaction-log/" target="_blank" rel="noopener">Paul Randel</a> has given very good sql code to check total number of page splits occurrence. Below is the code you need to run to get this details.</p>
<pre class="brush: sql; title: ; notranslate" title=""><strong><span style="color: #0000ff;">SELECT
[AllocUnitName] AS N'Index',
(CASE [Context]
WHEN N'LCX_INDEX_LEAF' THEN N'Nonclustered'
WHEN N'LCX_CLUSTERED' THEN N'Clustered'
ELSE N'Non-Leaf'
END) AS [SplitType],
COUNT (1) AS [SplitCount]
FROM
fn_dblog (NULL, NULL)
WHERE
[Operation] = N'LOP_DELETE_SPLIT'
GROUP BY [AllocUnitName], [Context];
GO
</span></strong></pre>
<p>You can check total number of page splits are shown for each indexes in below screenshot. Now we will discuss how to avoid page split in SQL Server for such indexes.</p>
<p><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-1144" src="http://techyaz.com/wp-content/uploads/2017/11/page-split-occurance.jpg" alt="Total number of page splits" width="553" height="421" srcset="https://techyaz.com/wp-content/uploads/2017/11/page-split-occurance.jpg 553w, https://techyaz.com/wp-content/uploads/2017/11/page-split-occurance-300x228.jpg 300w" sizes="auto, (max-width: 553px) 100vw, 553px" /></p>
<h3><span style="color: #333399;">How to Reduce Page Split Occurrences?</span></h3>
<p>An <a href="https://techyaz.com/sql-server/understanding-sql-server-indexes/" target="_blank" rel="noopener">index</a> that has many random inserts and has very full pages will have an increased number of page splits. This causes more fragmentation and that is very bad for performance. We can reduce page splits by keeping some room in the data pages by setting fill factor value less than 100. The extra bytes on each page will help to minimize page splits caused by extra length in the rows. Read attached article to understand <a href="https://techyaz.com/sql-server/what-should-be-the-best-value-for-fill-factor-in-sql-server/" target="_blank" rel="noopener">the best value for fill factor</a> to avoid such page-split operations.</p>
<p>We can also use <a href="https://techyaz.com/sql-server/difference-index-rebuild-reorganize/" target="_blank" rel="noopener">index rebuild operation</a> with the <a href="https://techyaz.com/sql-server/what-should-be-the-best-value-for-fill-factor-in-sql-server/" target="_blank" rel="noopener">FILL FACTOR</a> option that will allow the page fullness to be changed to fit the query pattern on the index. This will also helpful in reducing total page-split counts.<br />
I hope you like this article. You can drop your questions in comment section. 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/how-to-avoid-page-split-in-sql-server/">How to Avoid Page Split 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/how-to-avoid-page-split-in-sql-server/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
