<?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>performance &#8211; Database Research &amp; Development</title>
	<atom:link href="https://www.dbrnd.com/tag/performance/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>Fri, 08 Feb 2019 18:51:23 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.0.6</generator>
	<item>
		<title>Database Design: Please do not use DISTINCT</title>
		<link>https://www.dbrnd.com/2019/02/database-design-please-do-not-use-distinct-keyword-remove-duplicate-data/</link>
					<comments>https://www.dbrnd.com/2019/02/database-design-please-do-not-use-distinct-keyword-remove-duplicate-data/#comments</comments>
		
		<dc:creator><![CDATA[Anvesh Patel]]></dc:creator>
		<pubDate>Mon, 04 Feb 2019 16:16:09 +0000</pubDate>
				<category><![CDATA[Database Designing]]></category>
		<category><![CDATA[Anvesh Patel]]></category>
		<category><![CDATA[best practice]]></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 Theory]]></category>
		<category><![CDATA[database topic]]></category>
		<category><![CDATA[dbrnd]]></category>
		<category><![CDATA[DISTINCT]]></category>
		<category><![CDATA[group by]]></category>
		<category><![CDATA[performance]]></category>
		<category><![CDATA[RDBMS]]></category>
		<guid isPermaLink="false">https://www.dbrnd.com/?p=4130</guid>

					<description><![CDATA[<div><img width="336" height="336" src="https://www.dbrnd.com/wp-content/uploads/2016/12/DatabaseDesignAngryDistinct.jpg" class="attachment-post-image size-post-image wp-post-image" alt="database design angry distinct" decoding="async" fetchpriority="high" srcset="https://www.dbrnd.com/wp-content/uploads/2016/12/DatabaseDesignAngryDistinct.jpg 336w, https://www.dbrnd.com/wp-content/uploads/2016/12/DatabaseDesignAngryDistinct-150x150.jpg 150w, https://www.dbrnd.com/wp-content/uploads/2016/12/DatabaseDesignAngryDistinct-300x300.jpg 300w" sizes="(max-width: 336px) 100vw, 336px" /></div>I am telling you personally that I hate the use of DISTINCT. DISTINCT used by those people, who are not sure about their data set or SELECT statement or JOINS. Whenever I get any query with DISTINCT, immediately I suggest to remove it. I asked to many developers that, does it makes sense to use [&#8230;]]]></description>
										<content:encoded><![CDATA[<div><img width="336" height="336" src="https://www.dbrnd.com/wp-content/uploads/2016/12/DatabaseDesignAngryDistinct.jpg" class="attachment-post-image size-post-image wp-post-image" alt="database design angry distinct" decoding="async" srcset="https://www.dbrnd.com/wp-content/uploads/2016/12/DatabaseDesignAngryDistinct.jpg 336w, https://www.dbrnd.com/wp-content/uploads/2016/12/DatabaseDesignAngryDistinct-150x150.jpg 150w, https://www.dbrnd.com/wp-content/uploads/2016/12/DatabaseDesignAngryDistinct-300x300.jpg 300w" sizes="(max-width: 336px) 100vw, 336px" /></div><p><a class="a2a_button_facebook" href="https://www.addtoany.com/add_to/facebook?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2019%2F02%2Fdatabase-design-please-do-not-use-distinct-keyword-remove-duplicate-data%2F&amp;linkname=Database%20Design%3A%20Please%20do%20not%20use%20DISTINCT" 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%2F2019%2F02%2Fdatabase-design-please-do-not-use-distinct-keyword-remove-duplicate-data%2F&amp;linkname=Database%20Design%3A%20Please%20do%20not%20use%20DISTINCT" 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%2F2019%2F02%2Fdatabase-design-please-do-not-use-distinct-keyword-remove-duplicate-data%2F&amp;linkname=Database%20Design%3A%20Please%20do%20not%20use%20DISTINCT" 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%2F2019%2F02%2Fdatabase-design-please-do-not-use-distinct-keyword-remove-duplicate-data%2F&amp;linkname=Database%20Design%3A%20Please%20do%20not%20use%20DISTINCT" 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%2F2019%2F02%2Fdatabase-design-please-do-not-use-distinct-keyword-remove-duplicate-data%2F&amp;linkname=Database%20Design%3A%20Please%20do%20not%20use%20DISTINCT" 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%2F2019%2F02%2Fdatabase-design-please-do-not-use-distinct-keyword-remove-duplicate-data%2F&amp;linkname=Database%20Design%3A%20Please%20do%20not%20use%20DISTINCT" 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%2F2019%2F02%2Fdatabase-design-please-do-not-use-distinct-keyword-remove-duplicate-data%2F&#038;title=Database%20Design%3A%20Please%20do%20not%20use%20DISTINCT" data-a2a-url="https://www.dbrnd.com/2019/02/database-design-please-do-not-use-distinct-keyword-remove-duplicate-data/" data-a2a-title="Database Design: Please do not use DISTINCT"></a></p><p><strong><img decoding="async" class="alignright wp-image-4137 size-medium" title="database design angry distinct" src="https://www.dbrnd.com/wp-content/uploads/2016/12/DatabaseDesignAngryDistinct-300x300.jpg" alt="database design angry distinct" width="300" height="300" srcset="https://www.dbrnd.com/wp-content/uploads/2016/12/DatabaseDesignAngryDistinct-300x300.jpg 300w, https://www.dbrnd.com/wp-content/uploads/2016/12/DatabaseDesignAngryDistinct-150x150.jpg 150w, https://www.dbrnd.com/wp-content/uploads/2016/12/DatabaseDesignAngryDistinct.jpg 336w" sizes="(max-width: 300px) 100vw, 300px" />I am telling you personally that I hate the use of DISTINCT.</strong></p>
<blockquote><p>DISTINCT used by those people, who are not sure about their data set or SELECT statement or JOINS.</p></blockquote>
<p><strong>Whenever I get any query with DISTINCT, immediately I suggest to remove it. </strong></p>
<blockquote><p>I asked to many developers that, does it makes sense to use DISTINCT or do we have any alternative?<br />
Second, I asked that Why are you required to use DISTINCT.</p></blockquote>
<p><strong>Guys, what are you thinking? What was that answer?</strong></p>
<blockquote><p>Very simple, they keep quiet for a minute and were telling like: we are using to avoid duplicate result set.</p></blockquote>
<blockquote><p>This is not the correct answer for the use of DISTINCT.</p></blockquote>
<blockquote><p>Actually, most of developers are using DISTINCT because they want to hide their mistakes. They are writing incorrect joins and hiding duplication of data.</p></blockquote>
<blockquote><p>This is not only for database developer, DBA is a same responsible for this. The DBA must stop the duplication of data.</p></blockquote>
<blockquote><p><em>The DBA should give the answer that how duplicates data inserted in the database and who is responsible for that duplication.</em></p></blockquote>
<p><strong>Do you think, the use of DISTINCT is good for query performance?</strong></p>
<blockquote><p>My answer is simply no. Why, because it fetches unnecessary duplicate data and returns unique from it.</p></blockquote>
<blockquote><p>You should know the logical sequence of SQL Query execution. In the logical sequence, DISTINCT execute after SELECT means It checks all the data first and after that It avoids the duplicate data.</p></blockquote>
<p><strong>As I have raised a question for DISTINCT, few developers asked me to use GROUP BY instead of DISTINCT.</strong></p>
<blockquote><p>My simple answer was, Please do not use anything to remove duplicates from your result set.</p></blockquote>
<blockquote><p>Explicitly, you should remove the duplicate data and then also If you require to count few unique master group data, you can use GROUP BY instead of DISTINCT.</p></blockquote>
]]></content:encoded>
					
					<wfw:commentRss>https://www.dbrnd.com/2019/02/database-design-please-do-not-use-distinct-keyword-remove-duplicate-data/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
			</item>
		<item>
		<title>SQL Server: How to configure MAXDOP Parameter (Max Degree of Parallelism)</title>
		<link>https://www.dbrnd.com/2018/01/sql-server-how-to-configure-maxdop-parameter-max-degree-of-parallelism/</link>
		
		<dc:creator><![CDATA[Anvesh Patel]]></dc:creator>
		<pubDate>Thu, 25 Jan 2018 16:16:37 +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[Max Degree of Parallelism]]></category>
		<category><![CDATA[MAXDOP]]></category>
		<category><![CDATA[maxdop query hint]]></category>
		<category><![CDATA[performance]]></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[SSMS]]></category>
		<category><![CDATA[TSQL]]></category>
		<guid isPermaLink="false">https://www.dbrnd.com/?p=4175</guid>

					<description><![CDATA[<div><img width="640" height="426" src="https://www.dbrnd.com/wp-content/uploads/2017/09/ParallelProcessing2.jpg" class="attachment-post-image size-post-image wp-post-image" alt="ParallelProcessing2" decoding="async" loading="lazy" /></div>SQL Server uses a Maximum Degree of Parallelism (MAXDOP) for achieving the parallel query processing to increase the query execution performance. The default setting of MAXDOP is 0 means your query execution plan chooses the maximum degree of parallelism automatically. Which is OK, but in big transaction system you should limit your query by specifying [&#8230;]]]></description>
										<content:encoded><![CDATA[<div><img width="640" height="426" src="https://www.dbrnd.com/wp-content/uploads/2017/09/ParallelProcessing2.jpg" class="attachment-post-image size-post-image wp-post-image" alt="ParallelProcessing2" decoding="async" loading="lazy" /></div><p><a class="a2a_button_facebook" href="https://www.addtoany.com/add_to/facebook?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2018%2F01%2Fsql-server-how-to-configure-maxdop-parameter-max-degree-of-parallelism%2F&amp;linkname=SQL%20Server%3A%20How%20to%20configure%20MAXDOP%20Parameter%20%28Max%20Degree%20of%20Parallelism%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%2F2018%2F01%2Fsql-server-how-to-configure-maxdop-parameter-max-degree-of-parallelism%2F&amp;linkname=SQL%20Server%3A%20How%20to%20configure%20MAXDOP%20Parameter%20%28Max%20Degree%20of%20Parallelism%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%2F2018%2F01%2Fsql-server-how-to-configure-maxdop-parameter-max-degree-of-parallelism%2F&amp;linkname=SQL%20Server%3A%20How%20to%20configure%20MAXDOP%20Parameter%20%28Max%20Degree%20of%20Parallelism%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%2F2018%2F01%2Fsql-server-how-to-configure-maxdop-parameter-max-degree-of-parallelism%2F&amp;linkname=SQL%20Server%3A%20How%20to%20configure%20MAXDOP%20Parameter%20%28Max%20Degree%20of%20Parallelism%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%2F2018%2F01%2Fsql-server-how-to-configure-maxdop-parameter-max-degree-of-parallelism%2F&amp;linkname=SQL%20Server%3A%20How%20to%20configure%20MAXDOP%20Parameter%20%28Max%20Degree%20of%20Parallelism%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%2F2018%2F01%2Fsql-server-how-to-configure-maxdop-parameter-max-degree-of-parallelism%2F&amp;linkname=SQL%20Server%3A%20How%20to%20configure%20MAXDOP%20Parameter%20%28Max%20Degree%20of%20Parallelism%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%2F2018%2F01%2Fsql-server-how-to-configure-maxdop-parameter-max-degree-of-parallelism%2F&#038;title=SQL%20Server%3A%20How%20to%20configure%20MAXDOP%20Parameter%20%28Max%20Degree%20of%20Parallelism%29" data-a2a-url="https://www.dbrnd.com/2018/01/sql-server-how-to-configure-maxdop-parameter-max-degree-of-parallelism/" data-a2a-title="SQL Server: How to configure MAXDOP Parameter (Max Degree of Parallelism)"></a></p><p>SQL Server uses a Maximum Degree of Parallelism (MAXDOP) for achieving the parallel query processing to increase the query execution performance. </p>
<blockquote><p>The default setting of MAXDOP is 0 means your query execution plan chooses the maximum degree of parallelism automatically. </p></blockquote>
<blockquote><p>Which is OK, but in big transaction system you should limit your query by specifying an explicit value of MAXDOP (Number of CPU Core for Parallel Query Execution). Which requires proper analysis of your system loads, CPU configuration and number of concurrent connections.</p></blockquote>
<p>Below are some different ways to change the value MAXDOP.</p>
<p><strong>Using SSMS:</strong></p>
<blockquote><p>In SSMS, right click on server go to Server Properties -> Advanced -> Parallelism -> Max Degree of Parallelism. Default is 0.
</p></blockquote>
<p><strong>Using sp_configure:<br />
</strong></p>
<pre class="crayon-plain-tag">sp_configure 'show advanced options', 1;
GO
RECONFIGURE WITH OVERRIDE;
GO
sp_configure 'max degree of parallelism', 8;
GO
RECONFIGURE WITH OVERRIDE;
GO</pre> </p>
<p><strong>Using MAXDOP hint option at query level:</strong></p>
<pre class="crayon-plain-tag">SELECT *
FROM [Person].[Address]
OPTION (MAXDOP 1)</pre> </p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>SQL Server: Frequently Restart a SQL Server is a bad practice</title>
		<link>https://www.dbrnd.com/2018/01/sql-server-frequently-restart-a-sql-server-is-a-bad-practice/</link>
					<comments>https://www.dbrnd.com/2018/01/sql-server-frequently-restart-a-sql-server-is-a-bad-practice/#comments</comments>
		
		<dc:creator><![CDATA[Anvesh Patel]]></dc:creator>
		<pubDate>Sun, 14 Jan 2018 16:16:49 +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[performance]]></category>
		<category><![CDATA[Restart SQL Server]]></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[TSQL]]></category>
		<guid isPermaLink="false">https://www.dbrnd.com/?p=4334</guid>

					<description><![CDATA[<div><img width="679" height="382" src="https://www.dbrnd.com/wp-content/uploads/2017/12/SQL-Dont-Do-It-679x382.jpg" class="attachment-post-image size-post-image wp-post-image" alt="SQL Dont Do It" decoding="async" loading="lazy" srcset="https://www.dbrnd.com/wp-content/uploads/2017/12/SQL-Dont-Do-It-679x382.jpg 679w, https://www.dbrnd.com/wp-content/uploads/2017/12/SQL-Dont-Do-It-1030x579.jpg 1030w, https://www.dbrnd.com/wp-content/uploads/2017/12/SQL-Dont-Do-It-850x478.jpg 850w, https://www.dbrnd.com/wp-content/uploads/2017/12/SQL-Dont-Do-It-1700x956.jpg 1700w, https://www.dbrnd.com/wp-content/uploads/2017/12/SQL-Dont-Do-It-1358x764.jpg 1358w, https://www.dbrnd.com/wp-content/uploads/2017/12/SQL-Dont-Do-It.jpg 1920w" sizes="auto, (max-width: 679px) 100vw, 679px" /></div>Yesterday, I was solving a performance issue of a client, and I found that their in-house DBAs scheduled to restart a SQL Server at every Sunday. I simply stopped my all tuning work and immediately set a meeting with DBA team. To restart a SQL Server, again and again, is a very bad practice and [&#8230;]]]></description>
										<content:encoded><![CDATA[<div><img width="679" height="382" src="https://www.dbrnd.com/wp-content/uploads/2017/12/SQL-Dont-Do-It-679x382.jpg" class="attachment-post-image size-post-image wp-post-image" alt="SQL Dont Do It" decoding="async" loading="lazy" srcset="https://www.dbrnd.com/wp-content/uploads/2017/12/SQL-Dont-Do-It-679x382.jpg 679w, https://www.dbrnd.com/wp-content/uploads/2017/12/SQL-Dont-Do-It-1030x579.jpg 1030w, https://www.dbrnd.com/wp-content/uploads/2017/12/SQL-Dont-Do-It-850x478.jpg 850w, https://www.dbrnd.com/wp-content/uploads/2017/12/SQL-Dont-Do-It-1700x956.jpg 1700w, https://www.dbrnd.com/wp-content/uploads/2017/12/SQL-Dont-Do-It-1358x764.jpg 1358w, https://www.dbrnd.com/wp-content/uploads/2017/12/SQL-Dont-Do-It.jpg 1920w" sizes="auto, (max-width: 679px) 100vw, 679px" /></div><p><a class="a2a_button_facebook" href="https://www.addtoany.com/add_to/facebook?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2018%2F01%2Fsql-server-frequently-restart-a-sql-server-is-a-bad-practice%2F&amp;linkname=SQL%20Server%3A%20Frequently%20Restart%20a%20SQL%20Server%20is%20a%20bad%20practice" 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%2F2018%2F01%2Fsql-server-frequently-restart-a-sql-server-is-a-bad-practice%2F&amp;linkname=SQL%20Server%3A%20Frequently%20Restart%20a%20SQL%20Server%20is%20a%20bad%20practice" 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%2F2018%2F01%2Fsql-server-frequently-restart-a-sql-server-is-a-bad-practice%2F&amp;linkname=SQL%20Server%3A%20Frequently%20Restart%20a%20SQL%20Server%20is%20a%20bad%20practice" 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%2F2018%2F01%2Fsql-server-frequently-restart-a-sql-server-is-a-bad-practice%2F&amp;linkname=SQL%20Server%3A%20Frequently%20Restart%20a%20SQL%20Server%20is%20a%20bad%20practice" 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%2F2018%2F01%2Fsql-server-frequently-restart-a-sql-server-is-a-bad-practice%2F&amp;linkname=SQL%20Server%3A%20Frequently%20Restart%20a%20SQL%20Server%20is%20a%20bad%20practice" 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%2F2018%2F01%2Fsql-server-frequently-restart-a-sql-server-is-a-bad-practice%2F&amp;linkname=SQL%20Server%3A%20Frequently%20Restart%20a%20SQL%20Server%20is%20a%20bad%20practice" 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%2F2018%2F01%2Fsql-server-frequently-restart-a-sql-server-is-a-bad-practice%2F&#038;title=SQL%20Server%3A%20Frequently%20Restart%20a%20SQL%20Server%20is%20a%20bad%20practice" data-a2a-url="https://www.dbrnd.com/2018/01/sql-server-frequently-restart-a-sql-server-is-a-bad-practice/" data-a2a-title="SQL Server: Frequently Restart a SQL Server is a bad practice"></a></p><p>Yesterday, I was solving a performance issue of a client, and I found that their in-house DBAs scheduled to restart a SQL Server at every Sunday.</p>
<p>I simply stopped my all tuning work and immediately set a meeting with DBA team.<br />
To restart a SQL Server, again and again, is a very bad practice and it leads to the biggest performance issue. </p>
<p><strong>You must be aware of the following points, before restarting a SQL Server.</strong></p>
<blockquote><p>A Plan Cache of SQL Server stores the precompiled execution plan for frequently executed of queries.<br />
It improves the query performance by reducing a cost of creating and compiling execution plan again and again. </p>
<p>Apparently, most of our queries are frequently executing. </p>
<p>Once you restart the SQL Server, it clears the Plan Cache area, and all your queries require to create a new query plan which degrades the performance. </p></blockquote>
<blockquote><p>A Buffer Pool of SQL Server, very capable of storing the result of your frequently executed queries. </p>
<p>It reduces the disk/io and improves the query performance by sending a result directly from the memory area.<br />
If a result is not available in the buffer pool, it fetches from the disk.</p>
<p>When you restart the SQL Server, it clears the Buffer Pool area, and it takes more time to fill it again. </p></blockquote>
<blockquote><p>The Dynamic Management Views and Functions of SQL Server, return server state information that can be used to monitor the health of a server instance, diagnose problems, and tune performance.</p>
<p>The DMVs and DMFs are the first tool for SQL DBA to monitor the health of SQL Server. The DMVs and DMFs store its data into the process space of sqlservr.exe.</p>
<p>Once you restart your SQL Server, it clears all DMVs and DMFs statistics by destroying the process of sqlservr.exe.</p></blockquote>
<blockquote><p>The rollback of uncommitted transactions of SQL Server, this is a part of SQL Server crash recovery which rollback all uncommitted transactions. </p>
<p>Now imagine that you are going to restart your SQL Server and few of queries are still running. </p>
<p>In this situation, SQL Server rollbacks all uncommitted transactions which degrade the performance and restart process might take more time to complete the action.</p></blockquote>
]]></content:encoded>
					
					<wfw:commentRss>https://www.dbrnd.com/2018/01/sql-server-frequently-restart-a-sql-server-is-a-bad-practice/feed/</wfw:commentRss>
			<slash:comments>5</slash:comments>
		
		
			</item>
		<item>
		<title>Database Design: Common Practices for Database Developers and Application Developers</title>
		<link>https://www.dbrnd.com/2016/12/database-design-common-practices-for-database-developers-and-application-developers/</link>
		
		<dc:creator><![CDATA[Anvesh Patel]]></dc:creator>
		<pubDate>Mon, 26 Dec 2016 17:37:29 +0000</pubDate>
				<category><![CDATA[Database Designing]]></category>
		<category><![CDATA[Anvesh Patel]]></category>
		<category><![CDATA[Application Developer]]></category>
		<category><![CDATA[Cluster Index]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[database concept]]></category>
		<category><![CDATA[Database Design]]></category>
		<category><![CDATA[Database Developer]]></category>
		<category><![CDATA[database research and development]]></category>
		<category><![CDATA[database standards]]></category>
		<category><![CDATA[Database Theory]]></category>
		<category><![CDATA[database topic]]></category>
		<category><![CDATA[dbrnd]]></category>
		<category><![CDATA[performance]]></category>
		<category><![CDATA[Performance Optimization]]></category>
		<category><![CDATA[RDBMS]]></category>
		<guid isPermaLink="false">https://www.dbrnd.com/?p=4117</guid>

					<description><![CDATA[<div><img width="448" height="318" src="https://www.dbrnd.com/wp-content/uploads/2016/12/DatabaseDesignBestPractices.jpg" class="attachment-post-image size-post-image wp-post-image" alt="Database Design Best Practices" decoding="async" loading="lazy" srcset="https://www.dbrnd.com/wp-content/uploads/2016/12/DatabaseDesignBestPractices.jpg 448w, https://www.dbrnd.com/wp-content/uploads/2016/12/DatabaseDesignBestPractices-300x213.jpg 300w, https://www.dbrnd.com/wp-content/uploads/2016/12/DatabaseDesignBestPractices-150x106.jpg 150w" sizes="auto, (max-width: 448px) 100vw, 448px" /></div>In this post, I am sharing the list of common practices for Database Designing which should follow by Database Developers and Application Developers. Foreign keys should have indexes on them, and it should often cover multiple columns base on the queries you need to execute. You should make sure about the referential integrity by enforcing [&#8230;]]]></description>
										<content:encoded><![CDATA[<div><img width="448" height="318" src="https://www.dbrnd.com/wp-content/uploads/2016/12/DatabaseDesignBestPractices.jpg" class="attachment-post-image size-post-image wp-post-image" alt="Database Design Best Practices" decoding="async" loading="lazy" srcset="https://www.dbrnd.com/wp-content/uploads/2016/12/DatabaseDesignBestPractices.jpg 448w, https://www.dbrnd.com/wp-content/uploads/2016/12/DatabaseDesignBestPractices-300x213.jpg 300w, https://www.dbrnd.com/wp-content/uploads/2016/12/DatabaseDesignBestPractices-150x106.jpg 150w" 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%2F2016%2F12%2Fdatabase-design-common-practices-for-database-developers-and-application-developers%2F&amp;linkname=Database%20Design%3A%20Common%20Practices%20for%20Database%20Developers%20and%20Application%20Developers" 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%2F12%2Fdatabase-design-common-practices-for-database-developers-and-application-developers%2F&amp;linkname=Database%20Design%3A%20Common%20Practices%20for%20Database%20Developers%20and%20Application%20Developers" 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%2F12%2Fdatabase-design-common-practices-for-database-developers-and-application-developers%2F&amp;linkname=Database%20Design%3A%20Common%20Practices%20for%20Database%20Developers%20and%20Application%20Developers" 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%2F12%2Fdatabase-design-common-practices-for-database-developers-and-application-developers%2F&amp;linkname=Database%20Design%3A%20Common%20Practices%20for%20Database%20Developers%20and%20Application%20Developers" 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%2F12%2Fdatabase-design-common-practices-for-database-developers-and-application-developers%2F&amp;linkname=Database%20Design%3A%20Common%20Practices%20for%20Database%20Developers%20and%20Application%20Developers" 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%2F12%2Fdatabase-design-common-practices-for-database-developers-and-application-developers%2F&amp;linkname=Database%20Design%3A%20Common%20Practices%20for%20Database%20Developers%20and%20Application%20Developers" 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%2F12%2Fdatabase-design-common-practices-for-database-developers-and-application-developers%2F&#038;title=Database%20Design%3A%20Common%20Practices%20for%20Database%20Developers%20and%20Application%20Developers" data-a2a-url="https://www.dbrnd.com/2016/12/database-design-common-practices-for-database-developers-and-application-developers/" data-a2a-title="Database Design: Common Practices for Database Developers and Application Developers"></a></p><p>In this post, I am sharing the list of common practices for Database Designing which should follow by Database Developers and Application Developers.</p>
<ul>
<li>Foreign keys should have indexes on them, and it should often cover multiple columns base on the queries you need to execute.</li>
<li>You should make sure about the referential integrity by enforcing the Foreign Keys.<br />
Choose right column for CLUSTER Index.</li>
<li>You should apply proper indexes and do not create duplicate indexes and avoid creation of unnecessary indexes.</li>
<li>You should not put auto-number data type as a PRIMARY KEY to join a FOREIGN KEY in a parent/child table relationship.</li>
<li>If your system is running large number of INSERT/DELETE, you should avoid frequent update of database Statistics.</li>
<li>You should choose the write data-type for your data columns.</li>
<li>Please separate big size of columns from main table and store in a different table.</li>
<li>You should apply proper column name.</li>
<li>Use proper data types for Latitude, Longitude, IP-Address, Network Address, Mac Address.</li>
<li>Use Natural Primary key rather than Surrogate Primary key. Natural Primary keys are keys base on an external meaningful data. Surrogate Primary key are keys base on an auto-increment number or values which have no meaning outside the system.</li>
<li>You must use Stored Procedures or Stored Functions.</li>
<li>Please avoid too much database normalization and try to design your database to achieve Database Normalization + Database Denormalization. You should design this combination to achieve the performance.</li>
<li>Avoid inappropriate or excessive use of cursors.</li>
<li>Avoid inappropriate use of Database Transactions (BEGIN&#8230;COMMIT).</li>
<li>Try to avoid the use of OR condition because an AND condition restricts the data set, whereas an OR condition grows it.</li>
<li>You should do detailed performance analysis on queries.</li>
<li>Try to use the Prepared SQL Statement which caches the compiled query and the execution plan for better performance. It will also better protect you against SQL injection attacks.</li>
<li>Please do not simplify your complex queries through the views.</li>
<li>Please do not use DISTINCT frequently. Many developers are using DISTINCT to hide duplicate data, but you should stop and remove the duplicate data.</li>
<li>Try to avoid Correlated Subqueries.</li>
<li>Do not store comma delimited list in a table.</li>
<li>Do not store JSON data in TEXT COLUMN, you should use JSON data type for it.</li>
<li>Please do not use comma separated table names in SELECT query, use explicit JOINs conditions to avoid internal Cartesian products.</li>
</ul>
<p>&nbsp;<br />
<strong>The list is not final yet, you guys can add/share a comment and make it final&#8230;</strong></p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>PostgreSQL: Increase the speed of UPDATE query using HOT UPDATE (Heap only tuple)</title>
		<link>https://www.dbrnd.com/2016/12/postgresql-increase-the-speed-of-update-query-using-hot-update-heap-only-tuple-mvcc-fill-factor-vacuum-fragmentation/</link>
					<comments>https://www.dbrnd.com/2016/12/postgresql-increase-the-speed-of-update-query-using-hot-update-heap-only-tuple-mvcc-fill-factor-vacuum-fragmentation/#comments</comments>
		
		<dc:creator><![CDATA[Anvesh Patel]]></dc:creator>
		<pubDate>Sun, 25 Dec 2016 13:28:47 +0000</pubDate>
				<category><![CDATA[PostgreSQL]]></category>
		<category><![CDATA[Anvesh Patel]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[database research and development]]></category>
		<category><![CDATA[dbrnd]]></category>
		<category><![CDATA[Fill Factor]]></category>
		<category><![CDATA[fragmentation]]></category>
		<category><![CDATA[HOT]]></category>
		<category><![CDATA[Hot only tuple]]></category>
		<category><![CDATA[MVCC]]></category>
		<category><![CDATA[performance]]></category>
		<category><![CDATA[plpgsql]]></category>
		<category><![CDATA[Postgres Query]]></category>
		<category><![CDATA[postgresql]]></category>
		<category><![CDATA[PostgreSQL Administrator]]></category>
		<category><![CDATA[PostgreSQL Error]]></category>
		<category><![CDATA[PostgreSQL Programming]]></category>
		<category><![CDATA[PostgreSQL Tips and Tricks]]></category>
		<category><![CDATA[UPDATE]]></category>
		<guid isPermaLink="false">https://www.dbrnd.com/?p=3708</guid>

					<description><![CDATA[What is HOT UPDATE (Heap Only Tuple) and How It helps to increase the performance of UPDATE Query? In this post, I am going to explain the answer of this question. This is one of the internal of PostgreSQL, but I am sure that most of you guys don&#8217;t know about PostgreSQL HOT. PostgreSQL requires [&#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%2F12%2Fpostgresql-increase-the-speed-of-update-query-using-hot-update-heap-only-tuple-mvcc-fill-factor-vacuum-fragmentation%2F&amp;linkname=PostgreSQL%3A%20Increase%20the%20speed%20of%20UPDATE%20query%20using%20HOT%20UPDATE%20%28Heap%20only%20tuple%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%2F12%2Fpostgresql-increase-the-speed-of-update-query-using-hot-update-heap-only-tuple-mvcc-fill-factor-vacuum-fragmentation%2F&amp;linkname=PostgreSQL%3A%20Increase%20the%20speed%20of%20UPDATE%20query%20using%20HOT%20UPDATE%20%28Heap%20only%20tuple%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%2F12%2Fpostgresql-increase-the-speed-of-update-query-using-hot-update-heap-only-tuple-mvcc-fill-factor-vacuum-fragmentation%2F&amp;linkname=PostgreSQL%3A%20Increase%20the%20speed%20of%20UPDATE%20query%20using%20HOT%20UPDATE%20%28Heap%20only%20tuple%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%2F12%2Fpostgresql-increase-the-speed-of-update-query-using-hot-update-heap-only-tuple-mvcc-fill-factor-vacuum-fragmentation%2F&amp;linkname=PostgreSQL%3A%20Increase%20the%20speed%20of%20UPDATE%20query%20using%20HOT%20UPDATE%20%28Heap%20only%20tuple%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%2F12%2Fpostgresql-increase-the-speed-of-update-query-using-hot-update-heap-only-tuple-mvcc-fill-factor-vacuum-fragmentation%2F&amp;linkname=PostgreSQL%3A%20Increase%20the%20speed%20of%20UPDATE%20query%20using%20HOT%20UPDATE%20%28Heap%20only%20tuple%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%2F12%2Fpostgresql-increase-the-speed-of-update-query-using-hot-update-heap-only-tuple-mvcc-fill-factor-vacuum-fragmentation%2F&amp;linkname=PostgreSQL%3A%20Increase%20the%20speed%20of%20UPDATE%20query%20using%20HOT%20UPDATE%20%28Heap%20only%20tuple%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%2F12%2Fpostgresql-increase-the-speed-of-update-query-using-hot-update-heap-only-tuple-mvcc-fill-factor-vacuum-fragmentation%2F&#038;title=PostgreSQL%3A%20Increase%20the%20speed%20of%20UPDATE%20query%20using%20HOT%20UPDATE%20%28Heap%20only%20tuple%29" data-a2a-url="https://www.dbrnd.com/2016/12/postgresql-increase-the-speed-of-update-query-using-hot-update-heap-only-tuple-mvcc-fill-factor-vacuum-fragmentation/" data-a2a-title="PostgreSQL: Increase the speed of UPDATE query using HOT UPDATE (Heap only tuple)"></a></p><p><strong>What is HOT UPDATE (Heap Only Tuple) and How It helps to increase the performance of UPDATE Query?</strong><br />
In this post, I am going to explain the answer of this question. </p>
<blockquote><p>This is one of the internal of PostgreSQL, but I am sure that most of you guys don&#8217;t know about PostgreSQL HOT. </p></blockquote>
<p><strong>PostgreSQL requires HOT because of MVCC architecture.</strong><br />
Please read below articles, before start to knowing about the HOT. </p>
<blockquote><p><a href="https://www.dbrnd.com/2015/05/what-is-mvcc-multi-version-concurrency-control/" target="_blank"><strong>What is MVCC?</strong></a></p>
<p><a href="https://www.dbrnd.com/2016/03/postgresql-the-awesome-table-fillfactor-to-speedup-update-and-select-statement/" target="_blank"><strong>What is Fillfactor in PostgreSQL?</strong></a></p>
<p><a href="https://www.dbrnd.com/2015/11/postgresql-short-note-on-vacuum-vacuum-full-and-analyze/" target="_blank"><strong>What is Vacuum in PostgreSQL?</strong></a>
</p></blockquote>
<blockquote><p>In the MVCC architecture, When we update any record, internally MVCC architecture inserts a new record with new values and marks old record as deleted or discarded.<br />
When we vacuum, we can clean that deleted records and utilize that space.
</p></blockquote>
<p><strong>What is HOT (Hot Only Tuple)?</strong></p>
<blockquote><p>Now imagine that, we have total 500 data pages and we are updating record of page number 3, but unfortunately new record insert in page number 500. </p></blockquote>
<blockquote><p>It looks like very big internal fragmentation because of MVCC architecture.<br />
But actually this is not happening.</p></blockquote>
<blockquote><p>PostgreSQL has a concept of HOT, With a HOT dead tuple space can be automatically reclaimed at the time of INSERT or UPDATE if no changes are made to indexed columns. This allows for more consistent performance.</p></blockquote>
<blockquote><p>HOT means, creating a new update tuple if possible on the same page as the old tuple, and maintaining a chain of updated tuples linking a new version to the old tuple.</p></blockquote>
<blockquote><p>HOT updates can only reuse dead tuples from previous transactions directly, not from the same or concurrent ones.<br />
If you have big updates, changing large portions of the table at once, you might want to split them up in a couple of chunks.</p></blockquote>
<blockquote><p>HOT updates only work when the changed columns are not involved in indexes in any way because the indexes pointing the the old tuples need to point to the new version of it as of transaction id. </p></blockquote>
<blockquote><p>You might be blocking HOT updates with indexes on updated columns. If those are expendable, you might get better overall performance without them.</p></blockquote>
<p><strong>Let&#8217;s understand PostgreSQL HOT practically.</strong></p>
<p><strong>Create a table with Sample data: </strong></p>
<pre class="crayon-plain-tag">CREATE TABLE tbl_Employees
(
	EmpID INT
	,EmpName CHARACTER VARYING 	
	,EmpDepartment CHARACTER VARYING
	,EmpSalary INT
);
 
INSERT INTO tbl_Employees
VALUES 
(1,'Anvesh','Database',90000)
,(2,'Jenny','JAVA',65000)
,(3,'Martin','PHP',85000)
,(4,'Roy','PHP',94000)
,(5,'Eric','PHP',70000)
,(6,'Rajesh','Animation',50000)
,(7,'Mahi','Database',40000)
,(8,'Sofia','JAVA',60000);</pre> </p>
<p><strong>Delete one record:</strong></p>
<pre class="crayon-plain-tag">DELETE FROM tbl_Employees WHERE EmpID = 7;</pre> </p>
<p><strong>Insert one New Record:</strong></p>
<pre class="crayon-plain-tag">INSERT INTO tbl_Employees
VALUES 
(7,'Junik','Database',10000);</pre> </p>
<p><strong>Please check If any HOT Update or not on table:</strong></p>
<pre class="crayon-plain-tag">SELECT pg_stat_get_tuples_hot_updated('tbl_employees'::regclass::oid);
/*
Result:
pg_stat_get_tuples_hot_updated
------------------------------
0
*/</pre> </p>
<p><strong>Please update the statestic of that table:</strong></p>
<pre class="crayon-plain-tag">ANALYZE tbl_Employees;</pre> </p>
<p><strong>Now execute one more update command:</strong></p>
<pre class="crayon-plain-tag">UPDATE tbl_Employees SET EmpName = 'Robort' WHERE EmpID=7;</pre> </p>
<p><strong>Please check If any HOT Update or not on table:</strong></p>
<pre class="crayon-plain-tag">SELECT pg_stat_get_tuples_hot_updated('tbl_employees'::regclass::oid);
/*
Result:
pg_stat_get_tuples_hot_updated
------------------------------
1
*/</pre> </p>
<p><strong>Again, do more update:</strong></p>
<pre class="crayon-plain-tag">UPDATE tbl_Employees SET EmpName = 'Manish' WHERE EmpID=8;
UPDATE tbl_Employees SET EmpName = 'Cerlin' WHERE EmpID=4;</pre> </p>
<p><strong>Please check If any change in number of HOT Update of a table:</strong></p>
<pre class="crayon-plain-tag">SELECT pg_stat_get_tuples_hot_updated('tbl_employees'::regclass::oid);
/*
Result:
pg_stat_get_tuples_hot_updated
------------------------------
3
*/</pre> </p>
<p><strong>Now Apply, Index on EmpName Column:</strong></p>
<pre class="crayon-plain-tag">CREATE INDEX idx_tbl_employees_empname 
ON tbl_employees USING BTREE (EmpName);</pre> </p>
<p><strong>After Index, execute few more update:</strong></p>
<pre class="crayon-plain-tag">UPDATE tbl_Employees SET EmpName = 'Kulin' WHERE EmpID=3;
UPDATE tbl_Employees SET EmpName = 'Priya' WHERE EmpID=5;</pre> </p>
<p><strong>After Index, Please check If any change in number of HOT Update of a table:</strong><br />
The result is same because If column has an Index, HOT Update does not work.</p>
<pre class="crayon-plain-tag">SELECT pg_stat_get_tuples_hot_updated('tbl_employees'::regclass::oid);
/*
Result:
pg_stat_get_tuples_hot_updated
------------------------------
3
*/</pre> </p>
<p><strong>You can also check number of HOT update of current transaction:</strong></p>
<pre class="crayon-plain-tag">SELECT pg_stat_get_xact_tuples_hot_updated('tbl_employees'::regclass::oid);</pre> </p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.dbrnd.com/2016/12/postgresql-increase-the-speed-of-update-query-using-hot-update-heap-only-tuple-mvcc-fill-factor-vacuum-fragmentation/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
			</item>
		<item>
		<title>SQL Server: Script to find Outdated Index Statistics</title>
		<link>https://www.dbrnd.com/2016/12/sql-server-script-to-find-outdated-index-statistics-update-it-improve-query-performance/</link>
		
		<dc:creator><![CDATA[Anvesh Patel]]></dc:creator>
		<pubDate>Wed, 21 Dec 2016 03:46:22 +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[index]]></category>
		<category><![CDATA[Index Statistics]]></category>
		<category><![CDATA[performance]]></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[Statistics]]></category>
		<category><![CDATA[TSQL]]></category>
		<category><![CDATA[update statistics]]></category>
		<guid isPermaLink="false">https://www.dbrnd.com/?p=4060</guid>

					<description><![CDATA[In this post, I am sharing one script to find Outdated Index Statistics of SQL Server. Database Statistics are playing the main role to prepare a best query execution plan because Query Optimizer reads the Object Statistics and takes the decision accordingly. SQL Server Statistics stores information like: object meta-data, location information, number of 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%2F2016%2F12%2Fsql-server-script-to-find-outdated-index-statistics-update-it-improve-query-performance%2F&amp;linkname=SQL%20Server%3A%20Script%20to%20find%20Outdated%20Index%20Statistics" 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%2F12%2Fsql-server-script-to-find-outdated-index-statistics-update-it-improve-query-performance%2F&amp;linkname=SQL%20Server%3A%20Script%20to%20find%20Outdated%20Index%20Statistics" 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%2F12%2Fsql-server-script-to-find-outdated-index-statistics-update-it-improve-query-performance%2F&amp;linkname=SQL%20Server%3A%20Script%20to%20find%20Outdated%20Index%20Statistics" 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%2F12%2Fsql-server-script-to-find-outdated-index-statistics-update-it-improve-query-performance%2F&amp;linkname=SQL%20Server%3A%20Script%20to%20find%20Outdated%20Index%20Statistics" 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%2F12%2Fsql-server-script-to-find-outdated-index-statistics-update-it-improve-query-performance%2F&amp;linkname=SQL%20Server%3A%20Script%20to%20find%20Outdated%20Index%20Statistics" 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%2F12%2Fsql-server-script-to-find-outdated-index-statistics-update-it-improve-query-performance%2F&amp;linkname=SQL%20Server%3A%20Script%20to%20find%20Outdated%20Index%20Statistics" 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%2F12%2Fsql-server-script-to-find-outdated-index-statistics-update-it-improve-query-performance%2F&#038;title=SQL%20Server%3A%20Script%20to%20find%20Outdated%20Index%20Statistics" data-a2a-url="https://www.dbrnd.com/2016/12/sql-server-script-to-find-outdated-index-statistics-update-it-improve-query-performance/" data-a2a-title="SQL Server: Script to find Outdated Index Statistics"></a></p><p>In this post, I am sharing one script to find Outdated Index Statistics of SQL Server. </p>
<blockquote><p>Database Statistics are playing the main role to prepare a best query execution plan because Query Optimizer reads the Object Statistics and takes the decision accordingly.</p></blockquote>
<blockquote><p>SQL Server Statistics stores information like: object meta-data, location information, number of records.<br />
If your Object Statistics are not updated, It impacts your query performance so You should find outdated statistics and periodically, you should update the statistics data.</p></blockquote>
<blockquote class="wp-embedded-content" data-secret="wUbwAj9WoM"><p><a href="https://www.dbrnd.com/2016/11/sql-serverwarning-in-query-execution-plan-operator-used-tempdb-to-spill-data-during-execution-with-spill-level-2-sql-update-statistics-sp_updatestats/">SQL Server:Warning in Query Execution Plan, &#8220;Operator used tempdb to spill data during execution with spill level 2&#8221;</a></p></blockquote>
<p><iframe loading="lazy" class="wp-embedded-content" sandbox="allow-scripts" security="restricted"  src="https://www.dbrnd.com/2016/11/sql-serverwarning-in-query-execution-plan-operator-used-tempdb-to-spill-data-during-execution-with-spill-level-2-sql-update-statistics-sp_updatestats/embed/#?secret=wUbwAj9WoM" data-secret="wUbwAj9WoM" width="600" height="338" title="&#8220;SQL Server:Warning in Query Execution Plan, &#8220;Operator used tempdb to spill data during execution with spill level 2&#8221;&#8221; &#8212; Database Research &amp; Development" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe></p>
<p><strong>Script to find Outdated Index Statistics Information:</strong></p>
<pre class="crayon-plain-tag">SELECT 
	OBJECT_NAME(id)
	,name
	,STATS_DATE(id, indid)
	,rowmodctr
FROM sys.sysindexes
WHERE STATS_DATE(id, indid)&lt;=DATEADD(DAY,-1,GETDATE()) 
AND rowmodctr&gt;0 
AND id IN (SELECT object_id FROM sys.tables)
GO</pre> </p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Database Design: Don&#8217;t use, comma separated Tables in SELECT Query, Use Explicit JOINs</title>
		<link>https://www.dbrnd.com/2016/11/database-design-dont-use-comma-separated-tables-in-select-query-use-explicit-joins-optimized-join/</link>
		
		<dc:creator><![CDATA[Anvesh Patel]]></dc:creator>
		<pubDate>Wed, 30 Nov 2016 20:00:49 +0000</pubDate>
				<category><![CDATA[Database Designing]]></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 Theory]]></category>
		<category><![CDATA[database topic]]></category>
		<category><![CDATA[dbrnd]]></category>
		<category><![CDATA[explicit joins]]></category>
		<category><![CDATA[implicit joins]]></category>
		<category><![CDATA[joins optimization]]></category>
		<category><![CDATA[performance]]></category>
		<category><![CDATA[RDBMS]]></category>
		<guid isPermaLink="false">https://www.dbrnd.com/?p=3952</guid>

					<description><![CDATA[In online forums, I am observing one bad query practice. People are using multiple tables in the SELECT query by separating using commas. Bad Query Like: [crayon-6ab67c967c11b193669625/] Many of the Database Professionals are thinking that It is working like JOINs. I am writing this article in the &#8220;Database Designing&#8221; category, means It applies to all [&#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%2F11%2Fdatabase-design-dont-use-comma-separated-tables-in-select-query-use-explicit-joins-optimized-join%2F&amp;linkname=Database%20Design%3A%20Don%E2%80%99t%20use%2C%20comma%20separated%20Tables%20in%20SELECT%20Query%2C%20Use%20Explicit%20JOINs" 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%2F11%2Fdatabase-design-dont-use-comma-separated-tables-in-select-query-use-explicit-joins-optimized-join%2F&amp;linkname=Database%20Design%3A%20Don%E2%80%99t%20use%2C%20comma%20separated%20Tables%20in%20SELECT%20Query%2C%20Use%20Explicit%20JOINs" 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%2F11%2Fdatabase-design-dont-use-comma-separated-tables-in-select-query-use-explicit-joins-optimized-join%2F&amp;linkname=Database%20Design%3A%20Don%E2%80%99t%20use%2C%20comma%20separated%20Tables%20in%20SELECT%20Query%2C%20Use%20Explicit%20JOINs" 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%2F11%2Fdatabase-design-dont-use-comma-separated-tables-in-select-query-use-explicit-joins-optimized-join%2F&amp;linkname=Database%20Design%3A%20Don%E2%80%99t%20use%2C%20comma%20separated%20Tables%20in%20SELECT%20Query%2C%20Use%20Explicit%20JOINs" 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%2F11%2Fdatabase-design-dont-use-comma-separated-tables-in-select-query-use-explicit-joins-optimized-join%2F&amp;linkname=Database%20Design%3A%20Don%E2%80%99t%20use%2C%20comma%20separated%20Tables%20in%20SELECT%20Query%2C%20Use%20Explicit%20JOINs" 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%2F11%2Fdatabase-design-dont-use-comma-separated-tables-in-select-query-use-explicit-joins-optimized-join%2F&amp;linkname=Database%20Design%3A%20Don%E2%80%99t%20use%2C%20comma%20separated%20Tables%20in%20SELECT%20Query%2C%20Use%20Explicit%20JOINs" 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%2F11%2Fdatabase-design-dont-use-comma-separated-tables-in-select-query-use-explicit-joins-optimized-join%2F&#038;title=Database%20Design%3A%20Don%E2%80%99t%20use%2C%20comma%20separated%20Tables%20in%20SELECT%20Query%2C%20Use%20Explicit%20JOINs" data-a2a-url="https://www.dbrnd.com/2016/11/database-design-dont-use-comma-separated-tables-in-select-query-use-explicit-joins-optimized-join/" data-a2a-title="Database Design: Don’t use, comma separated Tables in SELECT Query, Use Explicit JOINs"></a></p><p><strong>In online forums, I am observing one  bad query practice. People are using multiple tables in the SELECT query by separating using commas.</strong><br />
<em>Bad Query Like:</em></p>
<pre class="crayon-plain-tag">SELECT * FROM a, b, c WHERE a.id = b.id AND b.id = c.id;</pre> </p>
<blockquote><p>Many of the Database Professionals are thinking that It is working like JOINs.
</p></blockquote>
<blockquote><p>I am writing this article in the &#8220;Database Designing&#8221; category, means It applies to all database professionals for knowing the truth of this kind of bad SQL Query. </p></blockquote>
<blockquote><p>When you write a query like above sample, internally Query Planner creates a virtual join between these tables and this is not a strait forward joins creation. A Query Planner has to check all possible combinations like: first join A TO B and then join C, join A TO C and then join B, join B TO C and then join A.</p></blockquote>
<blockquote><p>When you write such types of bad queries, Query Planner has to do additional work for joining the tables correctly and return the correct result.<br />
But actually It checks the data by creating a full Cartesian Product between these tables which is very costly and slow down the query performance. </p></blockquote>
<blockquote><p>We have taken example of three tables only, now let&#8217;s assume if we have 10 tables and people wrote a SELECT query using comma separated tables.<br />
So please I am requesting, never use such a bad query and try to write explicit JOINs in the SELECT Query.
</p></blockquote>
<p><strong>Another interesting point is:</strong></p>
<blockquote><p>When I discussed this point with our team, one of database developers said It is good that Query Planner is deciding the order of JOINS. If we give explicit joins, It may not be in the correct order all the times so let&#8217;s Query Planner to do. </p></blockquote>
<blockquote><p>My simple answer was:<br />
I am 5% agree with you, but do not forget that we are enough professional and can define the JOINs order correctly. We should not rely on Query Planner because It requires more internal I/O to just prepare a joins of the table.
</p></blockquote>
<p><strong>Correct Query should like:</strong></p>
<pre class="crayon-plain-tag">SELECT a.* FROM a JOIN b ON a.id=b.id JOIN c ON b.id=c.id</pre> </p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>PostgreSQL: Create Prepared Statement, to increase Session Performance</title>
		<link>https://www.dbrnd.com/2016/11/postgresql-create-prepared-statement-to-increase-session-performance-prevent-sql-injection/</link>
					<comments>https://www.dbrnd.com/2016/11/postgresql-create-prepared-statement-to-increase-session-performance-prevent-sql-injection/#comments</comments>
		
		<dc:creator><![CDATA[Anvesh Patel]]></dc:creator>
		<pubDate>Sun, 27 Nov 2016 17:04:08 +0000</pubDate>
				<category><![CDATA[PostgreSQL]]></category>
		<category><![CDATA[Anvesh Patel]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[database research and development]]></category>
		<category><![CDATA[dbrnd]]></category>
		<category><![CDATA[Parameterized Statements]]></category>
		<category><![CDATA[performance]]></category>
		<category><![CDATA[plpgsql]]></category>
		<category><![CDATA[Postgres Query]]></category>
		<category><![CDATA[postgresql]]></category>
		<category><![CDATA[PostgreSQL Administrator]]></category>
		<category><![CDATA[PostgreSQL Error]]></category>
		<category><![CDATA[PostgreSQL Programming]]></category>
		<category><![CDATA[PostgreSQL Tips and Tricks]]></category>
		<category><![CDATA[PREPARE]]></category>
		<category><![CDATA[Prepared Statements]]></category>
		<category><![CDATA[Session]]></category>
		<category><![CDATA[SQL Injection]]></category>
		<guid isPermaLink="false">https://www.dbrnd.com/?p=3933</guid>

					<description><![CDATA[The PostgreSQL Prepared Statement or Parameterized Statements are always good for specific purpose like: can create Prepared Statement for frequently executing query of a session, It also prevents from SQL Injections. Prepared Statements are faster for a particular session because It does not require parsing and compiling for each execution. It is only session specific [&#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%2F11%2Fpostgresql-create-prepared-statement-to-increase-session-performance-prevent-sql-injection%2F&amp;linkname=PostgreSQL%3A%20Create%20Prepared%20Statement%2C%20to%20increase%20Session%20Performance" 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%2F11%2Fpostgresql-create-prepared-statement-to-increase-session-performance-prevent-sql-injection%2F&amp;linkname=PostgreSQL%3A%20Create%20Prepared%20Statement%2C%20to%20increase%20Session%20Performance" 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%2F11%2Fpostgresql-create-prepared-statement-to-increase-session-performance-prevent-sql-injection%2F&amp;linkname=PostgreSQL%3A%20Create%20Prepared%20Statement%2C%20to%20increase%20Session%20Performance" 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%2F11%2Fpostgresql-create-prepared-statement-to-increase-session-performance-prevent-sql-injection%2F&amp;linkname=PostgreSQL%3A%20Create%20Prepared%20Statement%2C%20to%20increase%20Session%20Performance" 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%2F11%2Fpostgresql-create-prepared-statement-to-increase-session-performance-prevent-sql-injection%2F&amp;linkname=PostgreSQL%3A%20Create%20Prepared%20Statement%2C%20to%20increase%20Session%20Performance" 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%2F11%2Fpostgresql-create-prepared-statement-to-increase-session-performance-prevent-sql-injection%2F&amp;linkname=PostgreSQL%3A%20Create%20Prepared%20Statement%2C%20to%20increase%20Session%20Performance" 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%2F11%2Fpostgresql-create-prepared-statement-to-increase-session-performance-prevent-sql-injection%2F&#038;title=PostgreSQL%3A%20Create%20Prepared%20Statement%2C%20to%20increase%20Session%20Performance" data-a2a-url="https://www.dbrnd.com/2016/11/postgresql-create-prepared-statement-to-increase-session-performance-prevent-sql-injection/" data-a2a-title="PostgreSQL: Create Prepared Statement, to increase Session Performance"></a></p><p>The PostgreSQL Prepared Statement or Parameterized Statements are always good for specific purpose like: can create Prepared Statement for frequently executing query of a session, It also prevents from SQL Injections. </p>
<blockquote><p>Prepared Statements are faster for a particular session because It does not require parsing and compiling for each execution. It is only session specific and once a session kill, Prepared Statements automatically destroy. </p></blockquote>
<p>Here, You can access more on Prepared Statements. </p>
<blockquote class="wp-embedded-content" data-secret="XqVzPdXZbn"><p><a href="https://www.dbrnd.com/2015/08/prepared-or-parameterized-statements-in-database-system/">Prepared or Parameterized Statements in Database System</a></p></blockquote>
<p><iframe loading="lazy" class="wp-embedded-content" sandbox="allow-scripts" security="restricted"  src="https://www.dbrnd.com/2015/08/prepared-or-parameterized-statements-in-database-system/embed/#?secret=XqVzPdXZbn" data-secret="XqVzPdXZbn" width="600" height="338" title="&#8220;Prepared or Parameterized Statements in Database System&#8221; &#8212; Database Research &amp; Development" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe></p>
<p><strong>Small demonstration of PostgreSQL Prepared Statement:</strong></p>
<p><strong>Create a table with sample records:</strong></p>
<pre class="crayon-plain-tag">CREATE TABLE tbl_Students 
(
	StudID INTEGER PRIMARY KEY
	,StudName CHARACTER VARYING
	,StudClass CHAR(1)	
);

INSERT INTO tbl_Students 
VALUES (1,'Anvesh','A')
,(2,'Neevan','B'),(3,'Jenny','C')
,(4,'Roy','C'),(5,'Martin','C');</pre> </p>
<p><strong>Create a Prepared Statement to SELECT Students data:</strong></p>
<pre class="crayon-plain-tag">PREPARE pre_GetStudents (INT) AS 
SELECT *FROM tbl_Students WHERE StudID = $1;</pre> </p>
<p><strong>Execute a Prepared Statement:</strong></p>
<pre class="crayon-plain-tag">EXECUTE pre_GetStudents(2);</pre> </p>
<p><strong>System view to check the Prepare statements of session:</strong></p>
<pre class="crayon-plain-tag">SELECT *FROM pg_prepared_statements;</pre> </p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.dbrnd.com/2016/11/postgresql-create-prepared-statement-to-increase-session-performance-prevent-sql-injection/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
			</item>
		<item>
		<title>PostgreSQL: File System Level Backup to just Copy DATA Directory</title>
		<link>https://www.dbrnd.com/2016/09/postgresql-file-system-level-backup-to-just-copy-data-directory-fast-postgres-cluster-backup-restore/</link>
		
		<dc:creator><![CDATA[Anvesh Patel]]></dc:creator>
		<pubDate>Mon, 12 Sep 2016 19:35:10 +0000</pubDate>
				<category><![CDATA[PostgreSQL]]></category>
		<category><![CDATA[Anvesh Patel]]></category>
		<category><![CDATA[COPY]]></category>
		<category><![CDATA[copy postgres data directory]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[database research and development]]></category>
		<category><![CDATA[dbrnd]]></category>
		<category><![CDATA[File System Level Backup]]></category>
		<category><![CDATA[paste]]></category>
		<category><![CDATA[performance]]></category>
		<category><![CDATA[plpgsql]]></category>
		<category><![CDATA[Postgres Query]]></category>
		<category><![CDATA[postgresql]]></category>
		<category><![CDATA[PostgreSQL Administrator]]></category>
		<category><![CDATA[PostgreSQL Error]]></category>
		<category><![CDATA[PostgreSQL Programming]]></category>
		<category><![CDATA[PostgreSQL Tips and Tricks]]></category>
		<guid isPermaLink="false">https://www.dbrnd.com/?p=3637</guid>

					<description><![CDATA[For reading this article title, Please do not surprise. Yes, this is possible in PostgreSQL. We can simply copy the PostgreSQL DATA Directory and can use as a full PostgreSQL Database Server backup. The File System Level backup is not always recommended, but we can use this backup method in certain condition. In our organization, [&#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%2F09%2Fpostgresql-file-system-level-backup-to-just-copy-data-directory-fast-postgres-cluster-backup-restore%2F&amp;linkname=PostgreSQL%3A%20File%20System%20Level%20Backup%20to%20just%20Copy%20DATA%20Directory" 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%2F09%2Fpostgresql-file-system-level-backup-to-just-copy-data-directory-fast-postgres-cluster-backup-restore%2F&amp;linkname=PostgreSQL%3A%20File%20System%20Level%20Backup%20to%20just%20Copy%20DATA%20Directory" 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%2F09%2Fpostgresql-file-system-level-backup-to-just-copy-data-directory-fast-postgres-cluster-backup-restore%2F&amp;linkname=PostgreSQL%3A%20File%20System%20Level%20Backup%20to%20just%20Copy%20DATA%20Directory" 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%2F09%2Fpostgresql-file-system-level-backup-to-just-copy-data-directory-fast-postgres-cluster-backup-restore%2F&amp;linkname=PostgreSQL%3A%20File%20System%20Level%20Backup%20to%20just%20Copy%20DATA%20Directory" 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%2F09%2Fpostgresql-file-system-level-backup-to-just-copy-data-directory-fast-postgres-cluster-backup-restore%2F&amp;linkname=PostgreSQL%3A%20File%20System%20Level%20Backup%20to%20just%20Copy%20DATA%20Directory" 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%2F09%2Fpostgresql-file-system-level-backup-to-just-copy-data-directory-fast-postgres-cluster-backup-restore%2F&amp;linkname=PostgreSQL%3A%20File%20System%20Level%20Backup%20to%20just%20Copy%20DATA%20Directory" 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%2F09%2Fpostgresql-file-system-level-backup-to-just-copy-data-directory-fast-postgres-cluster-backup-restore%2F&#038;title=PostgreSQL%3A%20File%20System%20Level%20Backup%20to%20just%20Copy%20DATA%20Directory" data-a2a-url="https://www.dbrnd.com/2016/09/postgresql-file-system-level-backup-to-just-copy-data-directory-fast-postgres-cluster-backup-restore/" data-a2a-title="PostgreSQL: File System Level Backup to just Copy DATA Directory"></a></p><p><em>For reading this article title, Please do not surprise.<br />
Yes, this is possible in PostgreSQL. </em></p>
<p>We can simply copy the PostgreSQL DATA Directory and can use as a full PostgreSQL Database Server backup.</p>
<p><img loading="lazy" decoding="async" class="alignleft wp-image-3639 size-full" title="postgres files ystem backup" src="https://www.dbrnd.com/wp-content/uploads/2016/09/PostgresFileSystemBackup.png" alt="postgres files ystem backup" width="256" height="256" srcset="https://www.dbrnd.com/wp-content/uploads/2016/09/PostgresFileSystemBackup.png 256w, https://www.dbrnd.com/wp-content/uploads/2016/09/PostgresFileSystemBackup-150x150.png 150w" sizes="auto, (max-width: 256px) 100vw, 256px" /></p>
<p><strong>The File System Level backup is not always recommended, but we can use this backup method in certain condition. </strong></p>
<p>In our organization, I am managing PostgreSQL backup using two approaches.</p>
<blockquote><p>The First approach is a regular method for taking individual Database Backup using pgDump.</p></blockquote>
<blockquote><p>The Second approach is to take &#8220;frozen snapshot&#8221; of the PostgreSQL DATA directory. Our System Admin department is taking File System Level Backup of PostgreSQL.</p></blockquote>
<blockquote><p>Whenever I required new duplicate PostgreSQL server, I used this kind of file system backup of PostgreSQL.</p></blockquote>
<blockquote><p>It is faster than pgDump because It does not require any additional CPU I/O as full DATA directory already available on DISK.<br />
System Admin has to perform simple COPY and PASTE like any other file or folder.</p></blockquote>
<p><strong>Few Restrictions are:</strong></p>
<blockquote><p>The database server must be shut down in order to get a usable backup and disallowing all connections will not work.</p></blockquote>
<blockquote><p>It is impossible to restore only a table or few tables. A File system backups only work for complete backup and restoration of an entire database cluster.</p></blockquote>
<blockquote><p>If your data files and WAL log are on different disks, or if tablespaces are on different file systems, it might not be possible to use snapshot backup or file system level backup.</p></blockquote>
<blockquote><p>A file system backup will typically be larger than an SQL dump.</p></blockquote>
<blockquote><p>After restoring of file system backup, It requires to rebuild all your Database Indexes.(For improving the performance)</p></blockquote>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>SQL Server Database Administrator Interview Questions and Answers (Day-9)</title>
		<link>https://www.dbrnd.com/2016/07/sql-server-database-administrator-interview-questions-and-answers-service-broker-performance-statistics-fragmentations-day-9/</link>
					<comments>https://www.dbrnd.com/2016/07/sql-server-database-administrator-interview-questions-and-answers-service-broker-performance-statistics-fragmentations-day-9/#comments</comments>
		
		<dc:creator><![CDATA[Anvesh Patel]]></dc:creator>
		<pubDate>Sun, 17 Jul 2016 07:39:14 +0000</pubDate>
				<category><![CDATA[SQL Server Interview]]></category>
		<category><![CDATA[answers]]></category>
		<category><![CDATA[Anvesh Patel]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[database administrator]]></category>
		<category><![CDATA[database research and development]]></category>
		<category><![CDATA[dbrnd]]></category>
		<category><![CDATA[fragmentation]]></category>
		<category><![CDATA[Interviews]]></category>
		<category><![CDATA[performance]]></category>
		<category><![CDATA[questions]]></category>
		<category><![CDATA[Service Broker]]></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=3352</guid>

					<description><![CDATA[What is the use of Service Broker? Service Broker helps developers build asynchronous, loosely coupled applications in which independent components work together to accomplish a task. These application components exchange messages that contain the information that is required to complete the task. Service Broker can be useful for any application that needs to perform processing [&#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%2F07%2Fsql-server-database-administrator-interview-questions-and-answers-service-broker-performance-statistics-fragmentations-day-9%2F&amp;linkname=SQL%20Server%20Database%20Administrator%20Interview%20Questions%20and%20Answers%20%28Day-9%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%2F07%2Fsql-server-database-administrator-interview-questions-and-answers-service-broker-performance-statistics-fragmentations-day-9%2F&amp;linkname=SQL%20Server%20Database%20Administrator%20Interview%20Questions%20and%20Answers%20%28Day-9%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%2F07%2Fsql-server-database-administrator-interview-questions-and-answers-service-broker-performance-statistics-fragmentations-day-9%2F&amp;linkname=SQL%20Server%20Database%20Administrator%20Interview%20Questions%20and%20Answers%20%28Day-9%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%2F07%2Fsql-server-database-administrator-interview-questions-and-answers-service-broker-performance-statistics-fragmentations-day-9%2F&amp;linkname=SQL%20Server%20Database%20Administrator%20Interview%20Questions%20and%20Answers%20%28Day-9%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%2F07%2Fsql-server-database-administrator-interview-questions-and-answers-service-broker-performance-statistics-fragmentations-day-9%2F&amp;linkname=SQL%20Server%20Database%20Administrator%20Interview%20Questions%20and%20Answers%20%28Day-9%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%2F07%2Fsql-server-database-administrator-interview-questions-and-answers-service-broker-performance-statistics-fragmentations-day-9%2F&amp;linkname=SQL%20Server%20Database%20Administrator%20Interview%20Questions%20and%20Answers%20%28Day-9%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%2F07%2Fsql-server-database-administrator-interview-questions-and-answers-service-broker-performance-statistics-fragmentations-day-9%2F&#038;title=SQL%20Server%20Database%20Administrator%20Interview%20Questions%20and%20Answers%20%28Day-9%29" data-a2a-url="https://www.dbrnd.com/2016/07/sql-server-database-administrator-interview-questions-and-answers-service-broker-performance-statistics-fragmentations-day-9/" data-a2a-title="SQL Server Database Administrator Interview Questions and Answers (Day-9)"></a></p><p><strong>What is the use of Service Broker?</strong></p>
<blockquote><p>Service Broker helps developers build asynchronous, loosely coupled applications in which independent components work together to accomplish a task. These application components exchange messages that contain the information that is required to complete the task.</p>
<p>Service Broker can be useful for any application that needs to perform processing asynchronously, or that needs to distribute processing across a number of computers.</p></blockquote>
<p><strong>What are the main components of Service Broker?</strong></p>
<ul>
<li><strong>Conversation components:</strong> Conversation groups, conversations, and messages form the run-time structure of a Service Broker application. Applications exchange messages as part of a conversation.</li>
<li><strong>Service definition components:</strong> These are design-time components that specify the basic structure of the conversations that the application uses.</li>
<li><strong>Networking and security components:</strong> These components define the infrastructure used to exchange messages between instances of the Database Engine. To help database administrators manage</li>
<li><strong>Changing environments:</strong> Service Broker lets administrators configure these components independently of the application code.</li>
</ul>
<p><strong>What are the advantages of Service Broker?</strong></p>
<blockquote><p>Database integration enhances application performance and simplifies administration.</p>
<p>Message ordering and coordination for simplified application development</p>
<p>Loose application coupling provides workload flexibility.</p>
<p>Related message locking allows more than one instance of an application to process messages from the same queue without explicit synchronization.</p>
<p>Automatic activation allows applications to scale with the message volume.</p></blockquote>
<p><strong>I have a database which has several tables that have very heavy write operations. These table are very large and some are over a hundred gigabytes. I noticed performance of this database is getting slower and after some investigation we suspect that the Auto Update Statistics function is causing a performance degradation.</strong></p>
<p><strong>What should be your solution of this problem?</strong></p>
<blockquote><p>Statistics are objects which contain information about the distribution of values in one or more columns of a table or indexed view. The query optimizer uses this statistical data to estimate the number of rows in the query result. In the case where the statistics are invalid or outdated then the query optimizer is likely to choose a wrong execution plan and query performance will decrease. Therefore keeping statistics up to date is an essential part of SQL Server maintenance.</p>
<p>If we experience problems due to statistics automatically being updated then the solution might be to disable the Auto Update Statistics option. However, we cannot live with outdated statistics on large databases, so if you turn this option off you should create a scheduled job which explicitly updates the statistics during off-peak periods. To do this, we can use the sp_updatestats procedure.</p></blockquote>
<p><strong>What are the different type of Fragmentations?</strong></p>
<ul>
<li>Logical/Phsical Disk Fragmentation</li>
<li>Extent Fragmentation</li>
<li>File Fragmentation</li>
<li>Page Fragmentation</li>
<li>Index Fragmentation</li>
</ul>
<p><strong>What are the index statistics?</strong></p>
<blockquote><p>Index statistics contain information about the distribution of index key values. By distribution, I mean the number of rows associated with each key value. SQL Server uses this information to determine what kind of execution plan to use when processing a query.</p></blockquote>
<p><strong>When are index statistics updated?</strong></p>
<blockquote><p>The AUTO_UPDATE_STATISTICS database setting controls when statistics are automatically updated.  Once statistics have been created, SQL Server then determines when to update those statistics based on how out-of-date the statistics might be.</p>
<p>SQL Server identifies out of date statistics based on the number of inserts, updates, and deletes that have occurred since the last time statistics were updated, and then recreates the statistics based on a threshold. The threshold is relative to the number of records in the table. (Enable the properties – “auto create statistics” and “auto update statistics” for OLTP)</p></blockquote>
<p><strong>Explain database options “Auto Update Statistics” and “Auto Update Statistics Asynchronous”?</strong></p>
<blockquote><p>Auto Update Statistics: If there is an incoming query but statistics are stale then sql server first update the statistics before building the execution plan.</p>
<p>Auto Update Statistics Asynchronous: If there is an incoming query but statistics are stale then sql servers uses the stale statistics, builds the execution plan and then update the statistics.</p></blockquote>
<p><strong>How to update statistics manually?</strong></p>
<blockquote><p>If you want to manually update statistics, you can use either sp_updatestats or UPDATE STATISTICS &lt;statistics name&gt;</p></blockquote>
<p><strong>What are the various types of statistics available?</strong></p>
<p>There are three different types of statistics available.</p>
<ul>
<li>Statistics created due to index creation.</li>
<li>Statistics created by optimizer.</li>
<li>User defined statistics created from “CREATE STATISTICS”</li>
</ul>
<p><strong>What are the various options to be considered while designing a new execution plan?</strong></p>
<blockquote><p>There are a number of factors that influence the decision in choosing the proper execution plan. One of the most important ones are cardinality estimations, the process of calculating the number of qualifying rows that are likely after filtering operations are applied.</p>
<p>A query execution plan selected with inaccurate cardinality estimates can perform several orders of magnitude slower than one selected with accurate estimates. These cardinality estimations also influence plan design options, such as join-order and parallelism. Even memory allocation, the amount of memory that a query requests, is guided by cardinality estimations.</p></blockquote>
<p><strong>How to find out when statistics updated last time?</strong></p>
<blockquote><p>A simple logic is, run the query and observe the values for both “estimated rows” and “actual rows”, if they both are close to each other you need not worried about the statistics. If you find big difference between them then you need to think about updating statistics.</p>
<p>In general we can find out last statistics updated info from below query</p><pre class="crayon-plain-tag">select object_name(object_id) as table_name
,name as stats_name
,stats_date(object_id, stats_id) as last_update
from sys.stats
where objectproperty(object_id, ‘IsUserTable’) = 1
order by last_update</pre><p>
</p></blockquote>
<p><strong>What are the statistics in SQL Server?</strong></p>
<blockquote><p>Statistics determine the selectivity of the indexes. If an indexed column has unique values then the selectivity of that index is more, as opposed to an index with non-unique values. Query optimizer uses these indexes in determining whether to choose an index or not while executing a query.</p></blockquote>
<p><strong>In which situation you should update statistics?</strong></p>
<blockquote><p>If there is significant change in the key values in the index</p>
<p>If a large amount of data in an indexed column has been added, changed, or removed (that is, if the distribution of key values has changed), or the table has been truncated using the TRUNCATE TABLE statement and then repopulated</p>
<p>Database is upgraded from a previous version.</p></blockquote>
<p><strong>What are the steps to improve the performance of a query?</strong></p>
<ul>
<li>Number of joins and use of complex views/cursors have to be reduced.</li>
<li>The use of the stored procedures and indexes have to be maximized.</li>
<li>The optimized use of the complex conditional checks and computer columns have to be in place.</li>
<li>Tracking of performance analysis for the query helps us in identifying the right aspects to optimize.</li>
</ul>
<p><strong>Could you please give some Optimization Tips in writing SQL Queries ?</strong></p>
<ul>
<li>Always try to use views and stored procedures instead of doing work with heavy queries.</li>
<li>Make a habit to use constraints instead of triggers whenever it is possible.</li>
<li>When you need n number of row from database try to use top keyword or SET ROWCOUNT statement</li>
<li>Always use table variables in place of temporary tables.</li>
<li>Avoid Union and try to use UNION ALL statement.</li>
<li>Always avoid using the DISTINCT clause, whenever possible.</li>
<li>Always try to avoid using SQL Server cursors.</li>
<li>Always try to avoid the HAVING clause.</li>
<li>Do not use select count(*) to get number of rows</li>
<li>Try to include SET NOCOUNT ON statement into your stored procedures to stop the message indicating the number of rows affected by a T-SQL statement.</li>
<li>Always use file system to store large binary objects and use the file path in database.</li>
<li>Sometimes we may have to apply more than one sub queries in our main query. Try to minimize the number of sub query block in your query</li>
</ul>
]]></content:encoded>
					
					<wfw:commentRss>https://www.dbrnd.com/2016/07/sql-server-database-administrator-interview-questions-and-answers-service-broker-performance-statistics-fragmentations-day-9/feed/</wfw:commentRss>
			<slash:comments>4</slash:comments>
		
		
			</item>
	</channel>
</rss>
