<?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>heap table &#8211; Database Research &amp; Development</title>
	<atom:link href="https://www.dbrnd.com/tag/heap-table/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.dbrnd.com</link>
	<description>BIGData &#124; NoSQL &#124; MSSQL &#124; MySQL &#124; PostgreSQL</description>
	<lastBuildDate>Thu, 14 Dec 2017 17:40:39 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.0.4</generator>
	<item>
		<title>SQL Server: How to Remove Forwarded Records of a Heap Table?</title>
		<link>https://www.dbrnd.com/2017/11/sql-server-how-to-remove-forwarded-records-of-a-heap-table/</link>
		
		<dc:creator><![CDATA[Anvesh Patel]]></dc:creator>
		<pubDate>Sat, 04 Nov 2017 16:16:13 +0000</pubDate>
				<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[Anvesh Patel]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[database research and development]]></category>
		<category><![CDATA[dbrnd]]></category>
		<category><![CDATA[Forwarded Record]]></category>
		<category><![CDATA[fragmentation]]></category>
		<category><![CDATA[heap table]]></category>
		<category><![CDATA[REBUILD]]></category>
		<category><![CDATA[SQL Query]]></category>
		<category><![CDATA[SQL Server Administrator]]></category>
		<category><![CDATA[SQL Server Error]]></category>
		<category><![CDATA[SQL Server Monitoring]]></category>
		<category><![CDATA[SQL Server Performance Tuning]]></category>
		<category><![CDATA[SQL Server Programming]]></category>
		<category><![CDATA[SQL Server Tips and Tricks]]></category>
		<category><![CDATA[TSQL]]></category>
		<guid isPermaLink="false">https://www.dbrnd.com/?p=6304</guid>

					<description><![CDATA[In the previous two posts, I shared basic about Forwarding Records of Heap Table and shared a script to find the count of Forwarded Records in SQL Server. In this post, I am sharing a practical demonstration on Forwarding Records like generate Forwarding Records and then Remove those Forwarding Records. Please check the below full [&#8230;]]]></description>
										<content:encoded><![CDATA[<p><a class="a2a_button_facebook" href="https://www.addtoany.com/add_to/facebook?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2017%2F11%2Fsql-server-how-to-remove-forwarded-records-of-a-heap-table%2F&amp;linkname=SQL%20Server%3A%20How%20to%20Remove%20Forwarded%20Records%20of%20a%20Heap%20Table%3F" title="Facebook" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_twitter" href="https://www.addtoany.com/add_to/twitter?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2017%2F11%2Fsql-server-how-to-remove-forwarded-records-of-a-heap-table%2F&amp;linkname=SQL%20Server%3A%20How%20to%20Remove%20Forwarded%20Records%20of%20a%20Heap%20Table%3F" title="Twitter" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_linkedin" href="https://www.addtoany.com/add_to/linkedin?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2017%2F11%2Fsql-server-how-to-remove-forwarded-records-of-a-heap-table%2F&amp;linkname=SQL%20Server%3A%20How%20to%20Remove%20Forwarded%20Records%20of%20a%20Heap%20Table%3F" title="LinkedIn" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_pinterest" href="https://www.addtoany.com/add_to/pinterest?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2017%2F11%2Fsql-server-how-to-remove-forwarded-records-of-a-heap-table%2F&amp;linkname=SQL%20Server%3A%20How%20to%20Remove%20Forwarded%20Records%20of%20a%20Heap%20Table%3F" title="Pinterest" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_reddit" href="https://www.addtoany.com/add_to/reddit?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2017%2F11%2Fsql-server-how-to-remove-forwarded-records-of-a-heap-table%2F&amp;linkname=SQL%20Server%3A%20How%20to%20Remove%20Forwarded%20Records%20of%20a%20Heap%20Table%3F" title="Reddit" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_pocket" href="https://www.addtoany.com/add_to/pocket?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2017%2F11%2Fsql-server-how-to-remove-forwarded-records-of-a-heap-table%2F&amp;linkname=SQL%20Server%3A%20How%20to%20Remove%20Forwarded%20Records%20of%20a%20Heap%20Table%3F" title="Pocket" rel="nofollow noopener" target="_blank"></a><a class="a2a_dd addtoany_share_save addtoany_share" href="https://www.addtoany.com/share#url=https%3A%2F%2Fwww.dbrnd.com%2F2017%2F11%2Fsql-server-how-to-remove-forwarded-records-of-a-heap-table%2F&#038;title=SQL%20Server%3A%20How%20to%20Remove%20Forwarded%20Records%20of%20a%20Heap%20Table%3F" data-a2a-url="https://www.dbrnd.com/2017/11/sql-server-how-to-remove-forwarded-records-of-a-heap-table/" data-a2a-title="SQL Server: How to Remove Forwarded Records of a Heap Table?"></a></p><p>In the previous two posts, I shared basic about Forwarding Records of Heap Table and shared a script to find the count of Forwarded Records in SQL Server.</p>
<p>In this post, I am sharing a practical demonstration on Forwarding Records like generate Forwarding Records and then Remove those Forwarding Records.</p>
<p><strong>Please check the below full demonstration:</strong></p>
<p><strong>Create a sample HEAP table:</strong></p><pre class="crayon-plain-tag">CREATE TABLE tbl_Heap
(
	Col1 INT IDENTITY(1,1)
	,Col2 VARCHAR(1000)	
)
GO</pre><p>
<strong>Insert sample records with VARCHAR(5) size:</strong></p><pre class="crayon-plain-tag">INSERT INTO tbl_Heap (Col2) VALUES
('dbrnd')
GO 1000</pre><p>
<strong>Now, Update the data from VARCHAR(5) to VARCHAR(31):</strong></p><pre class="crayon-plain-tag">UPDATE tbl_Heap
SET Col2 = 'Database Research &amp; Development'
GO</pre><p>
<strong>Check the count of Forwarding Records:</strong></p>
<p><img decoding="async" class="alignnone size-full wp-image-6307" src="https://www.dbrnd.com/wp-content/uploads/2017/09/SQL-Server-Forwarded-Records.png" alt="" width="718" height="43" srcset="https://www.dbrnd.com/wp-content/uploads/2017/09/SQL-Server-Forwarded-Records.png 718w, https://www.dbrnd.com/wp-content/uploads/2017/09/SQL-Server-Forwarded-Records-679x41.png 679w" sizes="(max-width: 718px) 100vw, 718px" /></p>
<p><strong>For removing Forwarding Records, we should REBUILD the table:</strong></p><pre class="crayon-plain-tag">ALTER TABLE tbl_Heap REBUILD
GO</pre><p>
<strong>Now, Check the new count of Forwarding Records:</strong><br />
The count is 0 now.</p>
<p><img decoding="async" class="alignnone size-full wp-image-6308" src="https://www.dbrnd.com/wp-content/uploads/2017/09/SQL-Server-Forwarded-Records-Count.png" alt="" width="753" height="45" srcset="https://www.dbrnd.com/wp-content/uploads/2017/09/SQL-Server-Forwarded-Records-Count.png 753w, https://www.dbrnd.com/wp-content/uploads/2017/09/SQL-Server-Forwarded-Records-Count-679x41.png 679w" sizes="(max-width: 753px) 100vw, 753px" /></p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>SQL Server: Script to find the Forwarded Records count of a Table</title>
		<link>https://www.dbrnd.com/2017/11/sql-server-script-to-find-the-forwarded-records-count-of-a-table/</link>
		
		<dc:creator><![CDATA[Anvesh Patel]]></dc:creator>
		<pubDate>Fri, 03 Nov 2017 16:16:00 +0000</pubDate>
				<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQL Server DBA Script]]></category>
		<category><![CDATA[Anvesh Patel]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[database research and development]]></category>
		<category><![CDATA[dbrnd]]></category>
		<category><![CDATA[Forwarded Record]]></category>
		<category><![CDATA[fragmentation]]></category>
		<category><![CDATA[heap table]]></category>
		<category><![CDATA[SQL Query]]></category>
		<category><![CDATA[SQL Server Administrator]]></category>
		<category><![CDATA[SQL Server Error]]></category>
		<category><![CDATA[SQL Server Monitoring]]></category>
		<category><![CDATA[SQL Server Performance Tuning]]></category>
		<category><![CDATA[SQL Server Programming]]></category>
		<category><![CDATA[SQL Server Tips and Tricks]]></category>
		<category><![CDATA[TSQL]]></category>
		<guid isPermaLink="false">https://www.dbrnd.com/?p=6300</guid>

					<description><![CDATA[In the previous post, I shared basic about Forwarded Records in Heap table of SQL Server. In this post, I am sharing a script to check the count of Forwarded Records of a Table. In the below script, you can add a filter of your database and table for getting the number of Forwarding Records. [&#8230;]]]></description>
										<content:encoded><![CDATA[<p><a class="a2a_button_facebook" href="https://www.addtoany.com/add_to/facebook?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2017%2F11%2Fsql-server-script-to-find-the-forwarded-records-count-of-a-table%2F&amp;linkname=SQL%20Server%3A%20Script%20to%20find%20the%20Forwarded%20Records%20count%20of%20a%20Table" title="Facebook" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_twitter" href="https://www.addtoany.com/add_to/twitter?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2017%2F11%2Fsql-server-script-to-find-the-forwarded-records-count-of-a-table%2F&amp;linkname=SQL%20Server%3A%20Script%20to%20find%20the%20Forwarded%20Records%20count%20of%20a%20Table" title="Twitter" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_linkedin" href="https://www.addtoany.com/add_to/linkedin?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2017%2F11%2Fsql-server-script-to-find-the-forwarded-records-count-of-a-table%2F&amp;linkname=SQL%20Server%3A%20Script%20to%20find%20the%20Forwarded%20Records%20count%20of%20a%20Table" title="LinkedIn" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_pinterest" href="https://www.addtoany.com/add_to/pinterest?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2017%2F11%2Fsql-server-script-to-find-the-forwarded-records-count-of-a-table%2F&amp;linkname=SQL%20Server%3A%20Script%20to%20find%20the%20Forwarded%20Records%20count%20of%20a%20Table" title="Pinterest" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_reddit" href="https://www.addtoany.com/add_to/reddit?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2017%2F11%2Fsql-server-script-to-find-the-forwarded-records-count-of-a-table%2F&amp;linkname=SQL%20Server%3A%20Script%20to%20find%20the%20Forwarded%20Records%20count%20of%20a%20Table" title="Reddit" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_pocket" href="https://www.addtoany.com/add_to/pocket?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2017%2F11%2Fsql-server-script-to-find-the-forwarded-records-count-of-a-table%2F&amp;linkname=SQL%20Server%3A%20Script%20to%20find%20the%20Forwarded%20Records%20count%20of%20a%20Table" title="Pocket" rel="nofollow noopener" target="_blank"></a><a class="a2a_dd addtoany_share_save addtoany_share" href="https://www.addtoany.com/share#url=https%3A%2F%2Fwww.dbrnd.com%2F2017%2F11%2Fsql-server-script-to-find-the-forwarded-records-count-of-a-table%2F&#038;title=SQL%20Server%3A%20Script%20to%20find%20the%20Forwarded%20Records%20count%20of%20a%20Table" data-a2a-url="https://www.dbrnd.com/2017/11/sql-server-script-to-find-the-forwarded-records-count-of-a-table/" data-a2a-title="SQL Server: Script to find the Forwarded Records count of a Table"></a></p><p>In the previous post, I shared basic about Forwarded Records in Heap table of SQL Server.<br />
In this post, I am sharing a script to check the count of Forwarded Records of a Table. </p>
<p>In the below script, you can add a filter of your database and table for getting the number of Forwarding Records.</p>
<pre class="crayon-plain-tag">SELECT
	OBJECT_NAME(object_id) as TableName
	,index_type_desc
	,page_count
	,avg_page_space_used_in_percent
	,avg_record_size_in_bytes
	,forwarded_record_count
FROM sys.dm_db_index_physical_stats
(
	DB_ID('database_name')
	,OBJECT_ID('table_name')
	,NULL
	,NULL
	,'DETAILED'
)
GO</pre> </p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>SQL Server: Must know &#8211; the Forwarded Records in HEAP Table</title>
		<link>https://www.dbrnd.com/2017/11/sql-server-must-know-the-forwarded-records-in-heap-table/</link>
		
		<dc:creator><![CDATA[Anvesh Patel]]></dc:creator>
		<pubDate>Thu, 02 Nov 2017 16:16:31 +0000</pubDate>
				<category><![CDATA[Database Theory]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[Anvesh Patel]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[database research and development]]></category>
		<category><![CDATA[dbrnd]]></category>
		<category><![CDATA[Forwarded Records]]></category>
		<category><![CDATA[fragmentation]]></category>
		<category><![CDATA[heap table]]></category>
		<category><![CDATA[SQL Query]]></category>
		<category><![CDATA[SQL Server Administrator]]></category>
		<category><![CDATA[SQL Server Error]]></category>
		<category><![CDATA[SQL Server Monitoring]]></category>
		<category><![CDATA[SQL Server Performance Tuning]]></category>
		<category><![CDATA[SQL Server Programming]]></category>
		<category><![CDATA[SQL Server Tips and Tricks]]></category>
		<category><![CDATA[TSQL]]></category>
		<guid isPermaLink="false">https://www.dbrnd.com/?p=6296</guid>

					<description><![CDATA[<div><img width="600" height="400" src="https://www.dbrnd.com/wp-content/uploads/2016/12/PostgreSQLFragmentation.jpg" class="attachment-post-image size-post-image wp-post-image" alt="postgresql fragmentation" decoding="async" fetchpriority="high" srcset="https://www.dbrnd.com/wp-content/uploads/2016/12/PostgreSQLFragmentation.jpg 600w, https://www.dbrnd.com/wp-content/uploads/2016/12/PostgreSQLFragmentation-300x200.jpg 300w, https://www.dbrnd.com/wp-content/uploads/2016/12/PostgreSQLFragmentation-150x100.jpg 150w" sizes="(max-width: 600px) 100vw, 600px" /></div>In this post, I am sharing an important note on Forwarded Records in the Heap table of SQL Server. Whenever DBA or Developer is facing performance issue, they are always talking about the table or index fragmentation, but no-one is discussing the Forwarded Records. What is heap Table Simple Example to understand Forwarded Records: You [&#8230;]]]></description>
										<content:encoded><![CDATA[<div><img width="600" height="400" src="https://www.dbrnd.com/wp-content/uploads/2016/12/PostgreSQLFragmentation.jpg" class="attachment-post-image size-post-image wp-post-image" alt="postgresql fragmentation" decoding="async" loading="lazy" srcset="https://www.dbrnd.com/wp-content/uploads/2016/12/PostgreSQLFragmentation.jpg 600w, https://www.dbrnd.com/wp-content/uploads/2016/12/PostgreSQLFragmentation-300x200.jpg 300w, https://www.dbrnd.com/wp-content/uploads/2016/12/PostgreSQLFragmentation-150x100.jpg 150w" sizes="auto, (max-width: 600px) 100vw, 600px" /></div><p><a class="a2a_button_facebook" href="https://www.addtoany.com/add_to/facebook?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2017%2F11%2Fsql-server-must-know-the-forwarded-records-in-heap-table%2F&amp;linkname=SQL%20Server%3A%20Must%20know%20%E2%80%93%20the%20Forwarded%20Records%20in%20HEAP%20Table" title="Facebook" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_twitter" href="https://www.addtoany.com/add_to/twitter?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2017%2F11%2Fsql-server-must-know-the-forwarded-records-in-heap-table%2F&amp;linkname=SQL%20Server%3A%20Must%20know%20%E2%80%93%20the%20Forwarded%20Records%20in%20HEAP%20Table" title="Twitter" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_linkedin" href="https://www.addtoany.com/add_to/linkedin?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2017%2F11%2Fsql-server-must-know-the-forwarded-records-in-heap-table%2F&amp;linkname=SQL%20Server%3A%20Must%20know%20%E2%80%93%20the%20Forwarded%20Records%20in%20HEAP%20Table" title="LinkedIn" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_pinterest" href="https://www.addtoany.com/add_to/pinterest?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2017%2F11%2Fsql-server-must-know-the-forwarded-records-in-heap-table%2F&amp;linkname=SQL%20Server%3A%20Must%20know%20%E2%80%93%20the%20Forwarded%20Records%20in%20HEAP%20Table" title="Pinterest" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_reddit" href="https://www.addtoany.com/add_to/reddit?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2017%2F11%2Fsql-server-must-know-the-forwarded-records-in-heap-table%2F&amp;linkname=SQL%20Server%3A%20Must%20know%20%E2%80%93%20the%20Forwarded%20Records%20in%20HEAP%20Table" title="Reddit" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_pocket" href="https://www.addtoany.com/add_to/pocket?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2017%2F11%2Fsql-server-must-know-the-forwarded-records-in-heap-table%2F&amp;linkname=SQL%20Server%3A%20Must%20know%20%E2%80%93%20the%20Forwarded%20Records%20in%20HEAP%20Table" title="Pocket" rel="nofollow noopener" target="_blank"></a><a class="a2a_dd addtoany_share_save addtoany_share" href="https://www.addtoany.com/share#url=https%3A%2F%2Fwww.dbrnd.com%2F2017%2F11%2Fsql-server-must-know-the-forwarded-records-in-heap-table%2F&#038;title=SQL%20Server%3A%20Must%20know%20%E2%80%93%20the%20Forwarded%20Records%20in%20HEAP%20Table" data-a2a-url="https://www.dbrnd.com/2017/11/sql-server-must-know-the-forwarded-records-in-heap-table/" data-a2a-title="SQL Server: Must know – the Forwarded Records in HEAP Table"></a></p><p>In this post, I am sharing an important note on Forwarded Records in the Heap table of SQL Server. Whenever DBA or Developer is facing performance issue, they are always talking about the table or index fragmentation, but no-one is discussing the Forwarded Records. </p>
<blockquote class="wp-embedded-content" data-secret="zyVYXmfaV7"><p><a href="https://www.dbrnd.com/2015/08/what-is-heap-table/">What is heap Table</a></p></blockquote>
<p><iframe loading="lazy" class="wp-embedded-content" sandbox="allow-scripts" security="restricted"  src="https://www.dbrnd.com/2015/08/what-is-heap-table/embed/#?secret=zyVYXmfaV7" data-secret="zyVYXmfaV7" width="600" height="338" title="&#8220;What is heap Table&#8221; &#8212; Database Research &amp; Development" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe></p>
<p><strong>Simple Example to understand Forwarded Records:</strong></p>
<blockquote><p>You create a heap table, and one of the column types is VARCHAR(200).<br />
You inserted 100000 records and added a small size of the string in VARCHAR(200) like &#8220;dbrnd&#8221; value which is only VARCHAR(5).</p>
<p>Now next, you require updating the value from &#8220;dbrnd&#8221; to &#8220;Database Research &#038; Development&#8221; which is now VARCHAR(31).<br />
Previously, we stored our data based on VARCHAR(5), but while updating we need VARCHAR(31).</p>
<p>Before the update, all data correctly save in data page and for new update no more free space available on the data page. So SQL Server internally moves new data into the new page and assigned a new Relative Identifier (RID).</p>
<p>Now old page contains forwarding pointer to new RID and new records also back pointer to old records. </p></blockquote>
<p><em>&#8211; Called as Forwarded Records and which is also one type of internal fragmentation. </em></p>
<p><em>The biggest drawback of Forwarded Record is, it requires high I/O because SQL Server has to jump between the old data page and new data page for getting data. </em></p>
<p><strong>Few more following topics, which I will publish from tomorrow:</strong><br />
How to find the Forwarded Records?<br />
How to remove Forwarded Records?</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>SQL Server Interview: A Golden question, Can we disable the Clustered Index?</title>
		<link>https://www.dbrnd.com/2017/02/sql-server-interview-a-golden-question-can-we-disable-the-clustered-index-offline-table/</link>
					<comments>https://www.dbrnd.com/2017/02/sql-server-interview-a-golden-question-can-we-disable-the-clustered-index-offline-table/#comments</comments>
		
		<dc:creator><![CDATA[Anvesh Patel]]></dc:creator>
		<pubDate>Sat, 18 Feb 2017 16:16:16 +0000</pubDate>
				<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQL Server Interview]]></category>
		<category><![CDATA[Anvesh Patel]]></category>
		<category><![CDATA[Clustered Inded]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[database research and development]]></category>
		<category><![CDATA[dbrnd]]></category>
		<category><![CDATA[heap table]]></category>
		<category><![CDATA[Nonclustered Index]]></category>
		<category><![CDATA[Primary key]]></category>
		<category><![CDATA[SQL Query]]></category>
		<category><![CDATA[SQL Server Administrator]]></category>
		<category><![CDATA[SQL Server Error]]></category>
		<category><![CDATA[SQL Server Monitoring]]></category>
		<category><![CDATA[SQL Server Performance Tuning]]></category>
		<category><![CDATA[SQL Server Programming]]></category>
		<category><![CDATA[SQL Server Tips and Tricks]]></category>
		<category><![CDATA[TSQL]]></category>
		<guid isPermaLink="false">https://www.dbrnd.com/?p=4544</guid>

					<description><![CDATA[<div><img width="448" height="310" src="https://www.dbrnd.com/wp-content/uploads/2017/02/SQLServerSadClusteredIndex.jpg" class="attachment-post-image size-post-image wp-post-image" alt="SQLServerSadClusteredIndex" decoding="async" loading="lazy" srcset="https://www.dbrnd.com/wp-content/uploads/2017/02/SQLServerSadClusteredIndex.jpg 448w, https://www.dbrnd.com/wp-content/uploads/2017/02/SQLServerSadClusteredIndex-262x180.jpg 262w" sizes="auto, (max-width: 448px) 100vw, 448px" /></div> Many people asked me, Are you doing an only blogging or consulting? Every time my clear answer was, I am doing full-time Job as DB Lead in one of the leading IT Companies (working for 9 hours to 10 hours) and As you guys know, that I have shared loads of SQL Server Interview questions [&#8230;]]]></description>
										<content:encoded><![CDATA[<div><img width="448" height="310" src="https://www.dbrnd.com/wp-content/uploads/2017/02/SQLServerSadClusteredIndex.jpg" class="attachment-post-image size-post-image wp-post-image" alt="SQLServerSadClusteredIndex" decoding="async" loading="lazy" srcset="https://www.dbrnd.com/wp-content/uploads/2017/02/SQLServerSadClusteredIndex.jpg 448w, https://www.dbrnd.com/wp-content/uploads/2017/02/SQLServerSadClusteredIndex-262x180.jpg 262w" sizes="auto, (max-width: 448px) 100vw, 448px" /></div><p><a class="a2a_button_facebook" href="https://www.addtoany.com/add_to/facebook?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2017%2F02%2Fsql-server-interview-a-golden-question-can-we-disable-the-clustered-index-offline-table%2F&amp;linkname=SQL%20Server%20Interview%3A%20A%20Golden%20question%2C%20Can%20we%20disable%20the%20Clustered%20Index%3F" title="Facebook" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_twitter" href="https://www.addtoany.com/add_to/twitter?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2017%2F02%2Fsql-server-interview-a-golden-question-can-we-disable-the-clustered-index-offline-table%2F&amp;linkname=SQL%20Server%20Interview%3A%20A%20Golden%20question%2C%20Can%20we%20disable%20the%20Clustered%20Index%3F" title="Twitter" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_linkedin" href="https://www.addtoany.com/add_to/linkedin?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2017%2F02%2Fsql-server-interview-a-golden-question-can-we-disable-the-clustered-index-offline-table%2F&amp;linkname=SQL%20Server%20Interview%3A%20A%20Golden%20question%2C%20Can%20we%20disable%20the%20Clustered%20Index%3F" title="LinkedIn" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_pinterest" href="https://www.addtoany.com/add_to/pinterest?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2017%2F02%2Fsql-server-interview-a-golden-question-can-we-disable-the-clustered-index-offline-table%2F&amp;linkname=SQL%20Server%20Interview%3A%20A%20Golden%20question%2C%20Can%20we%20disable%20the%20Clustered%20Index%3F" title="Pinterest" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_reddit" href="https://www.addtoany.com/add_to/reddit?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2017%2F02%2Fsql-server-interview-a-golden-question-can-we-disable-the-clustered-index-offline-table%2F&amp;linkname=SQL%20Server%20Interview%3A%20A%20Golden%20question%2C%20Can%20we%20disable%20the%20Clustered%20Index%3F" title="Reddit" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_pocket" href="https://www.addtoany.com/add_to/pocket?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2017%2F02%2Fsql-server-interview-a-golden-question-can-we-disable-the-clustered-index-offline-table%2F&amp;linkname=SQL%20Server%20Interview%3A%20A%20Golden%20question%2C%20Can%20we%20disable%20the%20Clustered%20Index%3F" title="Pocket" rel="nofollow noopener" target="_blank"></a><a class="a2a_dd addtoany_share_save addtoany_share" href="https://www.addtoany.com/share#url=https%3A%2F%2Fwww.dbrnd.com%2F2017%2F02%2Fsql-server-interview-a-golden-question-can-we-disable-the-clustered-index-offline-table%2F&#038;title=SQL%20Server%20Interview%3A%20A%20Golden%20question%2C%20Can%20we%20disable%20the%20Clustered%20Index%3F" data-a2a-url="https://www.dbrnd.com/2017/02/sql-server-interview-a-golden-question-can-we-disable-the-clustered-index-offline-table/" data-a2a-title="SQL Server Interview: A Golden question, Can we disable the Clustered Index?"></a></p><p><em> Many people asked me, Are you doing an only blogging or consulting? Every time my clear answer was, I am doing full-time Job as DB Lead in one of the leading IT Companies (working for 9 hours to 10 hours) and </em></p>
<p>As you guys know, that I have shared loads of SQL Server Interview questions and answers.<br />
Let me tell you a story behind this,</p>
<blockquote><p>Whenever I free in a weekend; I always try to attend walk-in interviews which have been arranged by most of the IT Companies so that I can find some real interview questions and can share with you guys.</p></blockquote>
<p><em>Wait wait wait&#8230;.</em> I know most of the people are thinking that I am running for a job&#8230; which is false.</p>
<blockquote><p>I am not going to change my current company, but I am attending most of the interviews because I want to measure myself so that can share something more and can also take superb interviews that I am also doing in my current company. Additionally spending minimum 3 hours to 4 hours every day for blogging&#8230;</p></blockquote>
<p><em>I know, you guys are suffering my blah blah blah&#8230;. from the above two paragraphs, but for a golden question, you guys could suffer sometimes. </em></p>
<p>Last week, I attended a walk-in interview for DBA position at Tech Mahindra Hyderabad, India.<br />
They asked few questions on Clustered Index, and I was empty entirely.</p>
<p><strong>Questions were:</strong></p>
<ul>
<li>Can we disable the Clustered Index?</li>
<li>Have you ever tried to disable Clustered Index?</li>
<li>Once you disable the Clustered Index, Can we access the table?</li>
<li>Your table has Clustered Index + NonClustered Indexes. If you turn off the Clustered Index, Can you access your table using NonClustered Indexes?</li>
<li>Can we take the table in offline mode by disabling the Clustered Index?</li>
<li>Ok, If you disable the Clustered Index, how can you enable it again?</li>
</ul>
<p><strong>My simple answers were:</strong></p>
<ul>
<li>I don&#8217;t know it is possible or not</li>
<li>I never tried to disable the Primary key, and if it is possible</li>
<li>I don&#8217;t know how we can find the data path to access the table</li>
</ul>
<p>Now, I don&#8217;t want to write more blah, blah, blah&#8230; Find the below full demonstration and test it yourself and at the end, you will get all answers to above questions.</p>
<p><code>All the best....</code></p>
<p><em><strong>Now, one more question to you guys. If you have heap table, what ?, Can anyone share their thoughts via putting some comments?</strong></em></p>
<p><strong>Create a sample table:</strong><br />
<pre class="crayon-plain-tag">CREATE TABLE tbl_Students 
(
	StudID INT IDENTITY(1,1)
	,Name VARCHAR(10)
	,CONSTRAINT pk_tbl_Students_StudID PRIMARY KEY(StudID)
)
GO</pre>
<p><strong>Create a NonClustered index on Name column:</strong><br />
<pre class="crayon-plain-tag">CREATE NONCLUSTERED INDEX idx_tbl_Students_Name ON tbl_Students(Name)
GO</pre>
<p><strong>Insert 10000 dummy records:</strong><br />
<pre class="crayon-plain-tag">INSERT INTO tbl_Students(Name) VALUES ('Anvesh')
GO 10000</pre>
<p><strong>Now, Disable the Clustered Index:</strong><br />
It also disables the all Nonclustered Indexes of a table. You can check below warning message***<br />
<pre class="crayon-plain-tag">ALTER INDEX pk_tbl_Students_StudID ON dbo.tbl_Students DISABLE
GO</pre>
<pre class="crayon-plain-tag">Warning: Index 'idx_tbl_Students_Name' on table 'tbl_Students' was disabled as a result of disabling the clustered index on the table.</pre>
<p><strong>Try to select a table:</strong><br />
You will get a below error, You cannot select the table data because of query optimizer unable to find the access path of data.<br />
<pre class="crayon-plain-tag">SELECT *FROM tbl_Students
GO</pre>
<pre class="crayon-plain-tag">Msg 8655, Level 16, State 1, Line 1
The query processor is unable to produce a plan because the index 'pk_tbl_Students_StudID' on table or view 'tbl_Students' is disabled.</pre>
<p><strong>The solution is, Rebuild your Clustered Index and you will get your table back:</strong><br />
<pre class="crayon-plain-tag">ALTER INDEX pk_tbl_Students_StudID ON dbo.tbl_Students REBUILD
GO</pre>
]]></content:encoded>
					
					<wfw:commentRss>https://www.dbrnd.com/2017/02/sql-server-interview-a-golden-question-can-we-disable-the-clustered-index-offline-table/feed/</wfw:commentRss>
			<slash:comments>7</slash:comments>
		
		
			</item>
		<item>
		<title>SQL Server: Database Indexes Interview Questions and Answers (Day-4)</title>
		<link>https://www.dbrnd.com/2016/06/sql-server-database-indexes-interview-questions-and-answers-missing-index-online-index-enable-disable-index-day-4/</link>
		
		<dc:creator><![CDATA[Anvesh Patel]]></dc:creator>
		<pubDate>Sat, 11 Jun 2016 19:18:26 +0000</pubDate>
				<category><![CDATA[SQL Server Interview]]></category>
		<category><![CDATA[answers]]></category>
		<category><![CDATA[Anvesh Patel]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[database research and development]]></category>
		<category><![CDATA[dbrnd]]></category>
		<category><![CDATA[disable]]></category>
		<category><![CDATA[enable]]></category>
		<category><![CDATA[heap table]]></category>
		<category><![CDATA[indexes]]></category>
		<category><![CDATA[interview]]></category>
		<category><![CDATA[missing index]]></category>
		<category><![CDATA[online index]]></category>
		<category><![CDATA[questions]]></category>
		<category><![CDATA[SQL Query]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQL Server Administrator]]></category>
		<category><![CDATA[SQL Server Monitoring]]></category>
		<category><![CDATA[SQL Server Performance Tunning]]></category>
		<category><![CDATA[SQL Server Tips and Tricks]]></category>
		<category><![CDATA[TSQL]]></category>
		<guid isPermaLink="false">https://www.dbrnd.com/?p=2953</guid>

					<description><![CDATA[SQL Server: Script to find Heap Table without having an Index SQL Server: Script to find Index Average Fragmentation in Percentage SQL Server: Script to find Missing Indexes SQL Server: Script to find usage of Database Indexes SQL Server: Script to find Index Operational Stats What is your best practice to perform large-scale Index operations? [&#8230;]]]></description>
										<content:encoded><![CDATA[<p><a class="a2a_button_facebook" href="https://www.addtoany.com/add_to/facebook?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F06%2Fsql-server-database-indexes-interview-questions-and-answers-missing-index-online-index-enable-disable-index-day-4%2F&amp;linkname=SQL%20Server%3A%20Database%20Indexes%20Interview%20Questions%20and%20Answers%20%28Day-4%29" title="Facebook" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_twitter" href="https://www.addtoany.com/add_to/twitter?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F06%2Fsql-server-database-indexes-interview-questions-and-answers-missing-index-online-index-enable-disable-index-day-4%2F&amp;linkname=SQL%20Server%3A%20Database%20Indexes%20Interview%20Questions%20and%20Answers%20%28Day-4%29" title="Twitter" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_linkedin" href="https://www.addtoany.com/add_to/linkedin?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F06%2Fsql-server-database-indexes-interview-questions-and-answers-missing-index-online-index-enable-disable-index-day-4%2F&amp;linkname=SQL%20Server%3A%20Database%20Indexes%20Interview%20Questions%20and%20Answers%20%28Day-4%29" title="LinkedIn" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_pinterest" href="https://www.addtoany.com/add_to/pinterest?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F06%2Fsql-server-database-indexes-interview-questions-and-answers-missing-index-online-index-enable-disable-index-day-4%2F&amp;linkname=SQL%20Server%3A%20Database%20Indexes%20Interview%20Questions%20and%20Answers%20%28Day-4%29" title="Pinterest" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_reddit" href="https://www.addtoany.com/add_to/reddit?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F06%2Fsql-server-database-indexes-interview-questions-and-answers-missing-index-online-index-enable-disable-index-day-4%2F&amp;linkname=SQL%20Server%3A%20Database%20Indexes%20Interview%20Questions%20and%20Answers%20%28Day-4%29" title="Reddit" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_pocket" href="https://www.addtoany.com/add_to/pocket?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F06%2Fsql-server-database-indexes-interview-questions-and-answers-missing-index-online-index-enable-disable-index-day-4%2F&amp;linkname=SQL%20Server%3A%20Database%20Indexes%20Interview%20Questions%20and%20Answers%20%28Day-4%29" title="Pocket" rel="nofollow noopener" target="_blank"></a><a class="a2a_dd addtoany_share_save addtoany_share" href="https://www.addtoany.com/share#url=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F06%2Fsql-server-database-indexes-interview-questions-and-answers-missing-index-online-index-enable-disable-index-day-4%2F&#038;title=SQL%20Server%3A%20Database%20Indexes%20Interview%20Questions%20and%20Answers%20%28Day-4%29" data-a2a-url="https://www.dbrnd.com/2016/06/sql-server-database-indexes-interview-questions-and-answers-missing-index-online-index-enable-disable-index-day-4/" data-a2a-title="SQL Server: Database Indexes Interview Questions and Answers (Day-4)"></a></p><blockquote class="wp-embedded-content" data-secret="uN8lRznyum"><p><a href="https://www.dbrnd.com/2016/03/sql-server-script-to-find-heap-table-without-index/">SQL Server: Script to find Heap Table without having an Index</a></p></blockquote>
<p><iframe loading="lazy" class="wp-embedded-content" sandbox="allow-scripts" security="restricted"  src="https://www.dbrnd.com/2016/03/sql-server-script-to-find-heap-table-without-index/embed/#?secret=uN8lRznyum" data-secret="uN8lRznyum" width="600" height="338" title="&#8220;SQL Server: Script to find Heap Table without having an Index&#8221; &#8212; Database Research &amp; Development" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe></p>
<blockquote class="wp-embedded-content" data-secret="FcpzQ7b47t"><p><a href="https://www.dbrnd.com/2016/03/sql-server-script-to-find-index-average-fragmentation-in-percentage/">SQL Server: Script to find Index Average Fragmentation in Percentage</a></p></blockquote>
<p><iframe loading="lazy" class="wp-embedded-content" sandbox="allow-scripts" security="restricted"  src="https://www.dbrnd.com/2016/03/sql-server-script-to-find-index-average-fragmentation-in-percentage/embed/#?secret=FcpzQ7b47t" data-secret="FcpzQ7b47t" width="600" height="338" title="&#8220;SQL Server: Script to find Index Average Fragmentation in Percentage&#8221; &#8212; Database Research &amp; Development" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe></p>
<blockquote class="wp-embedded-content" data-secret="FohiXLtXej"><p><a href="https://www.dbrnd.com/2015/11/sql-server-script-to-find-missing-indexes/">SQL Server: Script to find Missing Indexes</a></p></blockquote>
<p><iframe loading="lazy" class="wp-embedded-content" sandbox="allow-scripts" security="restricted"  src="https://www.dbrnd.com/2015/11/sql-server-script-to-find-missing-indexes/embed/#?secret=FohiXLtXej" data-secret="FohiXLtXej" width="600" height="338" title="&#8220;SQL Server: Script to find Missing Indexes&#8221; &#8212; Database Research &amp; Development" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe></p>
<blockquote class="wp-embedded-content" data-secret="9LwtM8z0Sg"><p><a href="https://www.dbrnd.com/2015/10/sql-server-script-to-find-usage-of-database-indexes/">SQL Server: Script to find usage of Database Indexes</a></p></blockquote>
<p><iframe loading="lazy" class="wp-embedded-content" sandbox="allow-scripts" security="restricted"  src="https://www.dbrnd.com/2015/10/sql-server-script-to-find-usage-of-database-indexes/embed/#?secret=9LwtM8z0Sg" data-secret="9LwtM8z0Sg" width="600" height="338" title="&#8220;SQL Server: Script to find usage of Database Indexes&#8221; &#8212; Database Research &amp; Development" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe></p>
<blockquote class="wp-embedded-content" data-secret="ENjEBOINfX"><p><a href="https://www.dbrnd.com/2015/10/sql-server-script-to-find-index-operational-stats/">SQL Server: Script to find Index Operational Stats</a></p></blockquote>
<p><iframe loading="lazy" class="wp-embedded-content" sandbox="allow-scripts" security="restricted"  src="https://www.dbrnd.com/2015/10/sql-server-script-to-find-index-operational-stats/embed/#?secret=ENjEBOINfX" data-secret="ENjEBOINfX" width="600" height="338" title="&#8220;SQL Server: Script to find Index Operational Stats&#8221; &#8212; Database Research &amp; Development" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe></p>
<p><strong>What is your best practice to perform large-scale Index operations?</strong></p>
<blockquote><p>Make sure the transaction log has been backed up and truncated before running large-scale index operations online, and that the log has sufficient space to store the projected index and user transactions.</p>
<p>Consider setting the 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.</p>
<p>This allows for the transaction log of the user database to be truncated during the index operation if it is required.</p></blockquote>
<p><strong>What is Online Indexing?</strong></p>
<blockquote><p>The ONLINE option allows concurrent user access to the underlying table or clustered index data and any associated nonclustered indexes during these index operations.</p>
<p>DBAs can create, rebuild, or drop indexes online. The index operations on the underlying table can be performed concurrently with update or query operations.</p>
<p>The Online indexing feature is very helpful for environments that run 24 hours a day, seven days a week. The Online Indexing feature is available only in the Enterprise Editions.</p></blockquote>
<p><strong>Can we create index on table variables?</strong></p>
<blockquote><p>Creating an index on a table variable can be done implicitly within the declaration of the table variable by defining a primary key and creating unique constraints. The primary key will represent a clustered index, while the unique constraint a non clustered index.</p></blockquote>
<p><strong>What are your best practices to create an Index?</strong></p>
<ul>
<li>Understand the characteristics of the database (OLTP / OLAP).</li>
<li>Keep indexes lean.</li>
<li>Understand the characteristics of the most frequently used columns and queries.</li>
<li>Choose the right index type.</li>
<li>Create the clustered index on every table.</li>
<li>Keep the length of the index key short for clustered indexes.</li>
<li>Columns that are of the ntext, text, image, varchar(max), nvarchar(max), and varbinary(max) data types cannot be specified as index key columns.</li>
<li>Consider using filtered indexes on columns that have well-defined subsets.</li>
<li>Be sure to eliminate duplicate indexes, that is, multiple indexes created on the same set of columns.</li>
<li>Consider the order of the columns if the index will contain multiple columns.</li>
<li>Determine the Fill Factor.</li>
</ul>
<p><strong>How more indexes makes your INSERT slower?</strong></p>
<blockquote><p>The number of indexes on a table is the most dominant factor for insert performance. The more indexes a table has, the slower the execution becomes. The insert statement is the only operation that cannot directly benefit from indexing because it has no where clause.</p>
<p>Adding a new row to a table involves several steps. First, the database must find a place to store the row.</p>
<p>If there are indexes on the table, the database must make sure the new entry is also found via these indexes. For this reason it has to add the new entry to each and every index on that table. The number of indexes is therefore a multiplier for the cost of an insert statement.</p>
<p>Moreover, adding an entry to an index is much more expensive than inserting one into a heap structure because the database has to keep the index order and tree balance. That means the new entry cannot be written to any block—it belongs to a specific leaf node.</p>
<p>Once the correct leaf node has been identified, the database confirms that there is enough free space left in this node. If not, the database splits the leaf node and distributes the entries between the old and a new node.</p></blockquote>
<p><strong>Generally, when you should perform your index tunning exercise?</strong></p>
<blockquote><p>Index tuning isn’t something you do once a year. It’s something that you need to do iteratively– that means every month. Over time, data sizes change, user activity changes, and the SQL Server optimizer changes. Each of these things mean that indexes that are best for an application will also change. As you tune indexes, your query plans will change and you’re very likely to see more opportunities to add, drop, and combine indexes emerge. Because of this, you want to do a few changes every month.</p></blockquote>
<p><strong>Has default Index created on foreign key columns?</strong></p>
<blockquote><p>When a foreign key constraint is defined for a table, an index is not created by default by SQL Server.</p>
<p>However, it&#8217;s not uncommon for developers and database administrators to add them manually.</p>
<p>Indexes on foreign keys can provide performance benefits for table joins involving the primary and foreign key, and they can impact performance when the primary key value is updated, or if the row is deleted.</p></blockquote>
<p><strong>In which columns, you should consider your indexes?</strong></p>
<blockquote><p>Indexes should be considered on all columns that are frequently accessed by the WHERE, ORDER BY, GROUP BY, TOP, and DISTINCT clauses. Without an index, each of these operations will require a table scan of your table, potentially hurting performance.</p></blockquote>
<p><strong>When index needs change and you want to test how removing an index will affect performance, you have two options – you can disable or drop the index. Which is better?</strong></p>
<blockquote><p>DISABLING AN INDEX is better than to drop an Index.</p>
<p>When we Disable an Index, The metadata about the index is retained, as are the usage statistics in sys.dm_db_index_usage_stats.</p>
<p>The index is not usable by the query optimizer.</p>
<p>Disabling a nonclustered index will deallocate the index pages – the space is freed in the database.</p>
<p>Disabling a clustered index has additional effects. The data in the table still exists, but will be inaccessible for anything other than a drop or rebuild operation.</p></blockquote>
<p><strong>T-SQL Script to DISABLE an INDEX?</strong></p><pre class="crayon-plain-tag">ALTER INDEX IX_IndexName ON Schema.TableName DISABLE;</pre><p>
<strong>How you can re-enable the disable index?</strong></p>
<p>If you want to re-enable the index, you need to rebuild it.</p><pre class="crayon-plain-tag">ALTER INDEX IX_IndexName ON Schema.TableName REBUILD;</pre><p>
<strong>As a DBA, share your checklists and best practice for performance tuning of Indexes.</strong></p>
<ul>
<li>Periodically, run the Database Engine Tuning Advisor against current Profiler traces to identify potentially missing indexes.</li>
<li>Remove indexes that are never used.</li>
<li>Don’t accidentally create redundant indexes.</li>
<li>As a rule of thumb, every table should have at least a clustered index. Generally, but not always, the clustered index should be on a column that monotonically increases — such as an identity column, or some other column where the value is increasing — and is unique. In many cases, the primary key is the ideal column for a clustered index.</li>
<li>Since you can only create one clustered index per table, take extra time to carefully consider how it will be used. Consider the type of queries that will be used against the table, and make an educated guess as to which query (the most common one run against the table, perhaps) is the most critical, and if this query will benefit most from having a clustered index.</li>
<li>If a column in a table is not at least 95% unique, then most likely the query optimizer will not use a non-clustered index based on that column. Because of this, you generally don&#8217;t want to add non-clustered indexes to columns that aren&#8217;t at least 95% unique.</li>
<li>Keep the &#8220;width&#8221; of your indexes as narrow as possible. This reduces the size of the index and reduces the number of disk I/O reads required to read the index, boosting performance.</li>
<li>If possible, avoid adding a clustered index to a GUID column (uniqueidentifier data type).</li>
<li>Indexes should be considered on all columns that are frequently accessed by the JOIN, WHERE, ORDER BY, GROUP BY, TOP, and DISTINCT clauses.</li>
<li>Don&#8217;t automatically add indexes on a table because it seems like the right thing to do. Only add indexes if you know that they will be used by queries run against the table.</li>
<li>When creating indexes, try to make them unique indexes if at all possible. SQL Server can often search through a unique index faster than a non-unique index because in a unique index, each row is unique, and once the needed record is found, SQL Server doesn&#8217;t have to look any further.</li>
<li>If you perform regular joins between two or more tables in your queries, performance will be optimized if each of the joined columns have appropriate indexes.</li>
<li>Don’t automatically accept the default value of 100 for the fill factor for your indexes. It may or may not best meet your needs. A high fill factor is good for seldom changed data, but highly modified data needs a lower fill factor to reduce page splitting.</li>
<li>Don&#8217;t over index your OLTP tables, as every index you add increases the time it takes to perform INSERTS, UPDATES, and DELETES. There is a fine line between having the ideal number of indexes (for SELECTs) and the ideal number to minimize the overhead that occurs with indexes during data modifications.</li>
</ul>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>SQL Server: Script to find Heap Table without having an Index</title>
		<link>https://www.dbrnd.com/2016/03/sql-server-script-to-find-heap-table-without-index/</link>
		
		<dc:creator><![CDATA[Anvesh Patel]]></dc:creator>
		<pubDate>Mon, 21 Mar 2016 18:45:19 +0000</pubDate>
				<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQL Server DBA Script]]></category>
		<category><![CDATA[Anvesh Patel]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[database research and development]]></category>
		<category><![CDATA[dbrnd]]></category>
		<category><![CDATA[heap table]]></category>
		<category><![CDATA[index]]></category>
		<category><![CDATA[SQL Query]]></category>
		<category><![CDATA[SQL Server Administrator]]></category>
		<category><![CDATA[SQL Server Monitoring]]></category>
		<category><![CDATA[SQL Server Performance Tunning]]></category>
		<category><![CDATA[SQL Server Tips and Tricks]]></category>
		<category><![CDATA[SYS.INDEXES]]></category>
		<category><![CDATA[TSQL]]></category>
		<guid isPermaLink="false">https://www.dbrnd.com/?p=1998</guid>

					<description><![CDATA[In this post, I am sharing a script for a Database Administrator to find SQL Server Heap Tables which are not having a clustered index. A Table without a clustered index is called as Heap Table and Data is stored in the Heap without specifying an order. I have also published one article on, What [&#8230;]]]></description>
										<content:encoded><![CDATA[<p><a class="a2a_button_facebook" href="https://www.addtoany.com/add_to/facebook?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F03%2Fsql-server-script-to-find-heap-table-without-index%2F&amp;linkname=SQL%20Server%3A%20Script%20to%20find%20Heap%20Table%20without%20having%20an%20Index" title="Facebook" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_twitter" href="https://www.addtoany.com/add_to/twitter?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F03%2Fsql-server-script-to-find-heap-table-without-index%2F&amp;linkname=SQL%20Server%3A%20Script%20to%20find%20Heap%20Table%20without%20having%20an%20Index" title="Twitter" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_linkedin" href="https://www.addtoany.com/add_to/linkedin?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F03%2Fsql-server-script-to-find-heap-table-without-index%2F&amp;linkname=SQL%20Server%3A%20Script%20to%20find%20Heap%20Table%20without%20having%20an%20Index" title="LinkedIn" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_pinterest" href="https://www.addtoany.com/add_to/pinterest?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F03%2Fsql-server-script-to-find-heap-table-without-index%2F&amp;linkname=SQL%20Server%3A%20Script%20to%20find%20Heap%20Table%20without%20having%20an%20Index" title="Pinterest" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_reddit" href="https://www.addtoany.com/add_to/reddit?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F03%2Fsql-server-script-to-find-heap-table-without-index%2F&amp;linkname=SQL%20Server%3A%20Script%20to%20find%20Heap%20Table%20without%20having%20an%20Index" title="Reddit" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_pocket" href="https://www.addtoany.com/add_to/pocket?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F03%2Fsql-server-script-to-find-heap-table-without-index%2F&amp;linkname=SQL%20Server%3A%20Script%20to%20find%20Heap%20Table%20without%20having%20an%20Index" title="Pocket" rel="nofollow noopener" target="_blank"></a><a class="a2a_dd addtoany_share_save addtoany_share" href="https://www.addtoany.com/share#url=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F03%2Fsql-server-script-to-find-heap-table-without-index%2F&#038;title=SQL%20Server%3A%20Script%20to%20find%20Heap%20Table%20without%20having%20an%20Index" data-a2a-url="https://www.dbrnd.com/2016/03/sql-server-script-to-find-heap-table-without-index/" data-a2a-title="SQL Server: Script to find Heap Table without having an Index"></a></p><p>In this post, I am sharing a script for a Database Administrator to find SQL Server Heap Tables which are not having a clustered index. </p>
<p>A Table without a clustered index is called as Heap Table and Data is stored in the Heap without specifying an order. </p>
<p><a href="https://www.dbrnd.com/2015/08/what-is-heap-table/" target="_blank"><strong>I have also published one article on, What is Heap Table?<br />
You can visit this article here: </strong></a></p>
<p>Sometimes, database developer forgets to apply cluster index on a particular table and after that, the same table may have a lot of data which affect the query performance without having a clustered index. </p>
<p><strong>Below is a script:</strong></p>
<pre class="crayon-plain-tag">SELECT 
	OBJECT_NAME(object_id) AS TableName
	,type_desc AS TableType
	,allow_row_locks
	,allow_page_locks
FROM sys.indexes 
WHERE index_id = 0</pre> </p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>The Memory or Heap Storage Engine of MySQL</title>
		<link>https://www.dbrnd.com/2015/08/the-memory-or-heap-storage-engine-of-mysql/</link>
		
		<dc:creator><![CDATA[Anvesh Patel]]></dc:creator>
		<pubDate>Sat, 15 Aug 2015 20:06:12 +0000</pubDate>
				<category><![CDATA[Database Theory]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[.frm]]></category>
		<category><![CDATA[Anvesh Patel]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[database research and development]]></category>
		<category><![CDATA[heap table]]></category>
		<category><![CDATA[Memory Engine]]></category>
		<category><![CDATA[MySQL Command]]></category>
		<category><![CDATA[MySQL Database Administrator]]></category>
		<category><![CDATA[MySQL Database Designing]]></category>
		<category><![CDATA[MySQL Database Programming]]></category>
		<category><![CDATA[MySQL Error]]></category>
		<category><![CDATA[MySQL Performance Tunning]]></category>
		<category><![CDATA[MySQL Query]]></category>
		<category><![CDATA[MySQL Tips and Tricks]]></category>
		<guid isPermaLink="false">https://www.dbrnd.com/?p=405</guid>

					<description><![CDATA[In the previous post, I had explained the basic theory on the Heap Table of Database Technology. In this post, I am going to explain the Heap table terminology of MySQL. MySQL Memory Storage Engine also called as Heap Storage structure. Using Memory Storage Engine, you can store a table of data in server memory [&#8230;]]]></description>
										<content:encoded><![CDATA[<p><a class="a2a_button_facebook" href="https://www.addtoany.com/add_to/facebook?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2015%2F08%2Fthe-memory-or-heap-storage-engine-of-mysql%2F&amp;linkname=The%20Memory%20or%20Heap%20Storage%20Engine%20of%20MySQL" title="Facebook" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_twitter" href="https://www.addtoany.com/add_to/twitter?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2015%2F08%2Fthe-memory-or-heap-storage-engine-of-mysql%2F&amp;linkname=The%20Memory%20or%20Heap%20Storage%20Engine%20of%20MySQL" title="Twitter" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_linkedin" href="https://www.addtoany.com/add_to/linkedin?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2015%2F08%2Fthe-memory-or-heap-storage-engine-of-mysql%2F&amp;linkname=The%20Memory%20or%20Heap%20Storage%20Engine%20of%20MySQL" title="LinkedIn" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_pinterest" href="https://www.addtoany.com/add_to/pinterest?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2015%2F08%2Fthe-memory-or-heap-storage-engine-of-mysql%2F&amp;linkname=The%20Memory%20or%20Heap%20Storage%20Engine%20of%20MySQL" title="Pinterest" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_reddit" href="https://www.addtoany.com/add_to/reddit?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2015%2F08%2Fthe-memory-or-heap-storage-engine-of-mysql%2F&amp;linkname=The%20Memory%20or%20Heap%20Storage%20Engine%20of%20MySQL" title="Reddit" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_pocket" href="https://www.addtoany.com/add_to/pocket?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2015%2F08%2Fthe-memory-or-heap-storage-engine-of-mysql%2F&amp;linkname=The%20Memory%20or%20Heap%20Storage%20Engine%20of%20MySQL" title="Pocket" rel="nofollow noopener" target="_blank"></a><a class="a2a_dd addtoany_share_save addtoany_share" href="https://www.addtoany.com/share#url=https%3A%2F%2Fwww.dbrnd.com%2F2015%2F08%2Fthe-memory-or-heap-storage-engine-of-mysql%2F&#038;title=The%20Memory%20or%20Heap%20Storage%20Engine%20of%20MySQL" data-a2a-url="https://www.dbrnd.com/2015/08/the-memory-or-heap-storage-engine-of-mysql/" data-a2a-title="The Memory or Heap Storage Engine of MySQL"></a></p><p>In the previous post, I had explained the basic theory on the Heap Table of Database Technology.<br />
In this post, I am going to explain the Heap table terminology of MySQL.</p>
<blockquote><p>MySQL Memory Storage Engine also called as Heap Storage structure.</p></blockquote>
<p>Using Memory Storage Engine, you can store a table of data in server memory for fast retrieval.<br />
This table of data also supports B-Tree index so you can get a result in a best-optimized way. Auto_Increment also supported by the Tables of Memory Engine.</p>
<p>There might be chances of loss data when any hardware crashes or power outage of Server Memory.</p>
<blockquote><p>You can store and use only those data which are in temporary use and make sure that data in memory engine has always back up in physical stored table.</p></blockquote>
<p><strong>When to use Memory Engine of MySQL ?</strong></p>
<blockquote><p>If data are non-critical, need fast retrieval and only for read-only access with a minimum of updates.<br />
The volume of data can be fit into Memory area because it internally uses the swap out of virtual memory pages.</p></blockquote>
<p><strong>Brief details of Memory Engine Mechanism: </strong></p>
<blockquote><p>The table of Memory Engine stores it&#8217;s table definition into one disk file, and extension of this file is  .frm.<br />
All other data stores in a specified area of memory.<br />
The data in memory table is not only for one single connection, it is available for all running related connections and sessions of MySQL Server.</p></blockquote>
<p><strong>Create sample table using Memory Engine:</strong></p><pre class="crayon-plain-tag">CREATE TABLE Test (TestNo INT,TestName VARCHAR(50)) ENGINE = MEMORY;</pre><p>
This all basic about MySQL Memory or Heap Engine.</p>
<hr />
<p>Any confusion, like difference between Temporary table and Memory table.<br />
<a href="https://www.dbrnd.com/2015/08/mysql-temporary-table-vs-memory-table/" target="_blank">If yes, then please visit next post.</a></p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>What is heap Table</title>
		<link>https://www.dbrnd.com/2015/08/what-is-heap-table/</link>
		
		<dc:creator><![CDATA[Anvesh Patel]]></dc:creator>
		<pubDate>Sat, 15 Aug 2015 17:10:59 +0000</pubDate>
				<category><![CDATA[Database Theory]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[Anvesh Patel]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[database concept]]></category>
		<category><![CDATA[database research and development]]></category>
		<category><![CDATA[database standards]]></category>
		<category><![CDATA[database topic]]></category>
		<category><![CDATA[heap table]]></category>
		<category><![CDATA[RDBMS]]></category>
		<category><![CDATA[sql server heap]]></category>
		<guid isPermaLink="false">https://www.dbrnd.com/?p=396</guid>

					<description><![CDATA[You can find an N number of articles on Heap Tables. But still, I would like to write a theory on Heap Table. In simple term, Table without a clustered index is called as Heap Table. Data stored in a heap without specifying an order. Initially, data stored in the order of its inserted, but [&#8230;]]]></description>
										<content:encoded><![CDATA[<p><a class="a2a_button_facebook" href="https://www.addtoany.com/add_to/facebook?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2015%2F08%2Fwhat-is-heap-table%2F&amp;linkname=What%20is%20heap%20Table" title="Facebook" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_twitter" href="https://www.addtoany.com/add_to/twitter?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2015%2F08%2Fwhat-is-heap-table%2F&amp;linkname=What%20is%20heap%20Table" title="Twitter" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_linkedin" href="https://www.addtoany.com/add_to/linkedin?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2015%2F08%2Fwhat-is-heap-table%2F&amp;linkname=What%20is%20heap%20Table" title="LinkedIn" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_pinterest" href="https://www.addtoany.com/add_to/pinterest?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2015%2F08%2Fwhat-is-heap-table%2F&amp;linkname=What%20is%20heap%20Table" title="Pinterest" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_reddit" href="https://www.addtoany.com/add_to/reddit?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2015%2F08%2Fwhat-is-heap-table%2F&amp;linkname=What%20is%20heap%20Table" title="Reddit" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_pocket" href="https://www.addtoany.com/add_to/pocket?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2015%2F08%2Fwhat-is-heap-table%2F&amp;linkname=What%20is%20heap%20Table" title="Pocket" rel="nofollow noopener" target="_blank"></a><a class="a2a_dd addtoany_share_save addtoany_share" href="https://www.addtoany.com/share#url=https%3A%2F%2Fwww.dbrnd.com%2F2015%2F08%2Fwhat-is-heap-table%2F&#038;title=What%20is%20heap%20Table" data-a2a-url="https://www.dbrnd.com/2015/08/what-is-heap-table/" data-a2a-title="What is heap Table"></a></p><p>You can find an N number of articles on Heap Tables. But still, I would like to write a theory on Heap Table.</p>
<blockquote><p>In simple term, Table without a clustered index is called as Heap Table. Data stored in a heap without specifying an order.</p>
<p>Initially, data stored in the order of its inserted, but later database engine can move data around in the heap so you cannot predict the order of data, and because of this you have to write an ORDER BY clause for each and every use.</p></blockquote>
<p><strong>When you can use Heap Structure?</strong></p>
<p>Heap table is not advisable to use, but still, sometimes database architectures are using the Heap table.</p>
<blockquote><p>You can use Heap structure when the table is tiny. If a table has a slight amount of data, then you can use a Heap structure because in that condition Table Scan performs faster than Index Scan.</p></blockquote>
<p>Heap Structure use RID (Row Identifier) to fetch data from file and data page. RID contains file number, data page number and slot details of the page.</p>
<p><strong>When you should not use heap table?</strong></p>
<blockquote><p>Simple, when the amount of data is higher and require a predefined ORDER BY to the SELECT bulk of data.</p></blockquote>
<p>You cannot use a heap table when queries are frequently executing.<br />
You cannot use a heap table when data are grouped together because a group of the data is required proper ordered of data.</p>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
