<?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 Optimization &#8211; Database Research &amp; Development</title>
	<atom:link href="https://www.dbrnd.com/tag/performance-optimization/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>Mon, 05 Feb 2018 19:18:00 +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: 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" fetchpriority="high" 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="(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" 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="(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: Track ALL SQL Query Execution Statistics using pg_stat_statements Extension (Day 1/2)</title>
		<link>https://www.dbrnd.com/2016/09/postgresql-track-all-sql-query-execution-statistics-using-pg_stat_statements-extension-performance-tuning-query-optimization-day-1/</link>
					<comments>https://www.dbrnd.com/2016/09/postgresql-track-all-sql-query-execution-statistics-using-pg_stat_statements-extension-performance-tuning-query-optimization-day-1/#comments</comments>
		
		<dc:creator><![CDATA[Anvesh Patel]]></dc:creator>
		<pubDate>Fri, 09 Sep 2016 18:09:35 +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[log query execution]]></category>
		<category><![CDATA[Performance Optimization]]></category>
		<category><![CDATA[pg_stat_statements]]></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[query statistics]]></category>
		<guid isPermaLink="false">https://www.dbrnd.com/?p=3623</guid>

					<description><![CDATA[Are you facing performance related issues in PostgreSQL? Do you want to know all your SQL Query Execution Statistics like: How many times same query executed, What is total and average time for queries and others. If you are looking for these questions, this post is very helpful for you. PostgreSQL provides pg_stat_statements module or [&#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-track-all-sql-query-execution-statistics-using-pg_stat_statements-extension-performance-tuning-query-optimization-day-1%2F&amp;linkname=PostgreSQL%3A%20Track%20ALL%20SQL%20Query%20Execution%20Statistics%20using%20pg_stat_statements%20Extension%20%28Day%201%2F2%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%2F09%2Fpostgresql-track-all-sql-query-execution-statistics-using-pg_stat_statements-extension-performance-tuning-query-optimization-day-1%2F&amp;linkname=PostgreSQL%3A%20Track%20ALL%20SQL%20Query%20Execution%20Statistics%20using%20pg_stat_statements%20Extension%20%28Day%201%2F2%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%2F09%2Fpostgresql-track-all-sql-query-execution-statistics-using-pg_stat_statements-extension-performance-tuning-query-optimization-day-1%2F&amp;linkname=PostgreSQL%3A%20Track%20ALL%20SQL%20Query%20Execution%20Statistics%20using%20pg_stat_statements%20Extension%20%28Day%201%2F2%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%2F09%2Fpostgresql-track-all-sql-query-execution-statistics-using-pg_stat_statements-extension-performance-tuning-query-optimization-day-1%2F&amp;linkname=PostgreSQL%3A%20Track%20ALL%20SQL%20Query%20Execution%20Statistics%20using%20pg_stat_statements%20Extension%20%28Day%201%2F2%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%2F09%2Fpostgresql-track-all-sql-query-execution-statistics-using-pg_stat_statements-extension-performance-tuning-query-optimization-day-1%2F&amp;linkname=PostgreSQL%3A%20Track%20ALL%20SQL%20Query%20Execution%20Statistics%20using%20pg_stat_statements%20Extension%20%28Day%201%2F2%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%2F09%2Fpostgresql-track-all-sql-query-execution-statistics-using-pg_stat_statements-extension-performance-tuning-query-optimization-day-1%2F&amp;linkname=PostgreSQL%3A%20Track%20ALL%20SQL%20Query%20Execution%20Statistics%20using%20pg_stat_statements%20Extension%20%28Day%201%2F2%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%2F09%2Fpostgresql-track-all-sql-query-execution-statistics-using-pg_stat_statements-extension-performance-tuning-query-optimization-day-1%2F&#038;title=PostgreSQL%3A%20Track%20ALL%20SQL%20Query%20Execution%20Statistics%20using%20pg_stat_statements%20Extension%20%28Day%201%2F2%29" data-a2a-url="https://www.dbrnd.com/2016/09/postgresql-track-all-sql-query-execution-statistics-using-pg_stat_statements-extension-performance-tuning-query-optimization-day-1/" data-a2a-title="PostgreSQL: Track ALL SQL Query Execution Statistics using pg_stat_statements Extension (Day 1/2)"></a></p><blockquote><p><strong>Are you facing performance related issues in PostgreSQL?</strong></p></blockquote>
<blockquote><p>
<strong>Do you want to know all your SQL Query Execution Statistics like: How many times same query executed, What is total and average time for queries and others. </strong></p></blockquote>
<p>If you are looking for these questions, this post is very helpful for you. </p>
<blockquote><p>PostgreSQL provides pg_stat_statements module or extension which automatically records different types of statistic all running queries. </p></blockquote>
<blockquote><p>During the activity of Performance Optimization, We are always keen for long running queries of our Database Server. </p></blockquote>
<blockquote><p>We should configure pg_stat_statements module so that we can easily use require statistics for Performance Tuning.</p></blockquote>
<p><strong>Steps to configure and enable pg_stat_statements module:</strong></p>
<p><strong>First, Install pg_stat_statements Extension:</strong></p>
<pre class="crayon-plain-tag">CREATE EXTENSION pg_stat_statements;</pre> </p>
<p>Once we install the extension, It starts to log require query execution information in pg_stat_statements table.<br />
<strong>Select the data of pg_stat_statements:<br />
</strong></p>
<pre class="crayon-plain-tag">SELECT *FROM pg_stat_statements;</pre> </p>
<p><strong>If you get a below error, require to change few parameters in postgresql.conf file:</strong></p>
<pre class="crayon-plain-tag">ERROR:  pg_stat_statements must be loaded via shared_preload_libraries</pre> </p>
<blockquote><p>You can solve above error by changing this parameter in postgresql.conf file.<br />
After changes in postgresql.conf, restart PostgreSQL service. </p></blockquote>
<pre class="crayon-plain-tag">shared_preload_libraries = 'pg_stat_statements'
pg_stat_statements.max = 10000
pg_stat_statements.track = all</pre> </p>
<p><strong>Execute few sample queries to check, how pg_stat_statements works:</strong></p>
<pre class="crayon-plain-tag">CREATE TABLE tbl_ItemTransactions 
 (
     TranID SERIAL
     ,TransactionDate TIMESTAMPTZ
     ,TransactionName TEXT
 );

INSERT INTO tbl_ItemTransactions 
(TransactionDate, TransactionName)
SELECT x, 'dbrnd' 
FROM generate_series('2016-01-01 00:00:00'::timestamptz, '2016-12-31 23:59:59'::timestamptz,'2 seconds'::interval) a(x);

SELECT COUNT(1) FROM tbl_ItemTransactions;

SELECT *FROM tbl_ItemTransactions 
WHERE TransactionDate BETWEEN '2016-02-08' AND '2016-04-08';</pre> </p>
<p><strong>Check the tracked statistics in pg_stat_statements:</strong></p>
<pre class="crayon-plain-tag">SELECT *FROM pg_stat_statements;</pre> </p>
<p><strong>Using below function, You can also reset pg_stat_statements:</strong></p>
<pre class="crayon-plain-tag">SELECT *FROM pg_stat_statements_reset();</pre> </p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.dbrnd.com/2016/09/postgresql-track-all-sql-query-execution-statistics-using-pg_stat_statements-extension-performance-tuning-query-optimization-day-1/feed/</wfw:commentRss>
			<slash:comments>2</slash:comments>
		
		
			</item>
	</channel>
</rss>
