<?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>PostgreSQL Performance Tuning &#8211; Database Research &amp; Development</title>
	<atom:link href="https://www.dbrnd.com/tag/postgresql-performance-tuning/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, 24 Jun 2019 19:41:46 +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>PostgreSQL: Create Index on Full Text Search tsvector Data</title>
		<link>https://www.dbrnd.com/2019/07/postgresql-create-index-on-full-text-search-tsvector-data/</link>
					<comments>https://www.dbrnd.com/2019/07/postgresql-create-index-on-full-text-search-tsvector-data/#respond</comments>
		
		<dc:creator><![CDATA[Anvesh Patel]]></dc:creator>
		<pubDate>Mon, 22 Jul 2019 16:16:31 +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[Full Text Search]]></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 Monitoring]]></category>
		<category><![CDATA[PostgreSQL Performance Tuning]]></category>
		<category><![CDATA[PostgreSQL Programming]]></category>
		<category><![CDATA[PostgreSQL Tips and Tricks]]></category>
		<category><![CDATA[to_tsquery]]></category>
		<category><![CDATA[tsvector]]></category>
		<guid isPermaLink="false">https://www.dbrnd.com/?p=6968</guid>

					<description><![CDATA[In this post, I am sharing an example of applying Full Text Search on PostgreSQL Table with Index. Here, I am using tsvector for full text search which is document type and uses match operator like @@. PostgreSQL: Example of Trigram Index for Full Text Search using pg_trgm Extension Below is an example: Create a [&#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%2F2019%2F07%2Fpostgresql-create-index-on-full-text-search-tsvector-data%2F&amp;linkname=PostgreSQL%3A%20Create%20Index%20on%20Full%20Text%20Search%20tsvector%20Data" 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%2F07%2Fpostgresql-create-index-on-full-text-search-tsvector-data%2F&amp;linkname=PostgreSQL%3A%20Create%20Index%20on%20Full%20Text%20Search%20tsvector%20Data" 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%2F07%2Fpostgresql-create-index-on-full-text-search-tsvector-data%2F&amp;linkname=PostgreSQL%3A%20Create%20Index%20on%20Full%20Text%20Search%20tsvector%20Data" 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%2F07%2Fpostgresql-create-index-on-full-text-search-tsvector-data%2F&amp;linkname=PostgreSQL%3A%20Create%20Index%20on%20Full%20Text%20Search%20tsvector%20Data" 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%2F07%2Fpostgresql-create-index-on-full-text-search-tsvector-data%2F&amp;linkname=PostgreSQL%3A%20Create%20Index%20on%20Full%20Text%20Search%20tsvector%20Data" 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%2F07%2Fpostgresql-create-index-on-full-text-search-tsvector-data%2F&amp;linkname=PostgreSQL%3A%20Create%20Index%20on%20Full%20Text%20Search%20tsvector%20Data" 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%2F07%2Fpostgresql-create-index-on-full-text-search-tsvector-data%2F&#038;title=PostgreSQL%3A%20Create%20Index%20on%20Full%20Text%20Search%20tsvector%20Data" data-a2a-url="https://www.dbrnd.com/2019/07/postgresql-create-index-on-full-text-search-tsvector-data/" data-a2a-title="PostgreSQL: Create Index on Full Text Search tsvector Data"></a></p><p>In this post, I am sharing an example of applying Full Text Search on PostgreSQL Table with Index. </p>
<p>Here, I am using tsvector for full text search which is document type and uses match operator like @@.</p>
<blockquote class="wp-embedded-content" data-secret="FxWul5DgOM"><p><a href="https://www.dbrnd.com/2016/08/postgresql-example-of-trigram-index-for-full-text-search-using-pg_trgm-extension/">PostgreSQL: Example of Trigram Index for Full Text Search using pg_trgm Extension</a></p></blockquote>
<p><iframe class="wp-embedded-content" sandbox="allow-scripts" security="restricted"  src="https://www.dbrnd.com/2016/08/postgresql-example-of-trigram-index-for-full-text-search-using-pg_trgm-extension/embed/#?secret=FxWul5DgOM" data-secret="FxWul5DgOM" width="600" height="338" title="&#8220;PostgreSQL: Example of Trigram Index for Full Text Search using pg_trgm Extension&#8221; &#8212; Database Research &amp; Development" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe></p>
<p><strong>Below is an example:</strong></p>
<p><strong>Create a sample table with data:</strong></p>
<pre class="crayon-plain-tag">CREATE TABLE tbl_Textdata
(id int, txt character varying);

INSERT INTO tbl_Textdata VALUES
(1,'I am DBA'),(2,'database research &amp; development'),(3,'think for data only')
,(4,'data is important'),(5,'data is a future'),(6,'I am data owner');</pre> </p>
<p><strong>Do Full Text Searching:</strong></p>
<pre class="crayon-plain-tag">SELECT txt
FROM tbl_Textdata
WHERE to_tsvector(txt) @@ to_tsquery('data');</pre> </p>
<p><strong>Result:</strong></p>
<pre class="crayon-plain-tag">txt
--------------------------
'think for data only'
'data is important'
'data is a future'
'I am data owner'</pre> </p>
<p><strong>Apply an Index on require Text Pattern:</strong></p>
<pre class="crayon-plain-tag">CREATE INDEX tbl_Textdata_txt_idx ON tbl_Textdata USING GIN (to_tsvector('english',txt));</pre> </p>
<p><strong>Check the execution plan:</strong></p>
<pre class="crayon-plain-tag">explain analyze
SELECT txt
FROM tbl_Textdata
WHERE to_tsvector(txt) @@ to_tsquery('data');

'Seq Scan on tbl_textdata  (cost=0.00..4.07 rows=1 width=32) (actual time=0.043..0.058 rows=4 loops=1)'
'  Filter: (to_tsvector((txt)::text) @@ to_tsquery('data'::text))'
'  Rows Removed by Filter: 2'
'Planning time: 5.494 ms'
'Execution time: 0.083 ms'</pre> </p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.dbrnd.com/2019/07/postgresql-create-index-on-full-text-search-tsvector-data/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>PostgreSQL: Disable Non-Durable parameters and Improve Server Performance</title>
		<link>https://www.dbrnd.com/2019/06/postgresql-disable-non-durable-parameters-and-improve-server-performance/</link>
					<comments>https://www.dbrnd.com/2019/06/postgresql-disable-non-durable-parameters-and-improve-server-performance/#respond</comments>
		
		<dc:creator><![CDATA[Anvesh Patel]]></dc:creator>
		<pubDate>Mon, 10 Jun 2019 16:16:22 +0000</pubDate>
				<category><![CDATA[PostgreSQL]]></category>
		<category><![CDATA[Anvesh Patel]]></category>
		<category><![CDATA[checkpoint_timeout]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[database research and development]]></category>
		<category><![CDATA[dbrnd]]></category>
		<category><![CDATA[fsync]]></category>
		<category><![CDATA[full_page_writes]]></category>
		<category><![CDATA[max_wal_size]]></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 Monitoring]]></category>
		<category><![CDATA[PostgreSQL Performance Tuning]]></category>
		<category><![CDATA[PostgreSQL Programming]]></category>
		<category><![CDATA[PostgreSQL Tips and Tricks]]></category>
		<category><![CDATA[synchronous_commit]]></category>
		<guid isPermaLink="false">https://www.dbrnd.com/?p=6920</guid>

					<description><![CDATA[Important notice: Never try in your Production or any other Live server. This post is only ad-hoc and test server. Data Durability is an important part of Database ACID property. In this post, I am sharing few parameters which we can disable for achieving good performance of PostgreSQL Database Server. We should disable Non-Durable parameters [&#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%2F2019%2F06%2Fpostgresql-disable-non-durable-parameters-and-improve-server-performance%2F&amp;linkname=PostgreSQL%3A%20Disable%20Non-Durable%20parameters%20and%20Improve%20Server%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%2F2019%2F06%2Fpostgresql-disable-non-durable-parameters-and-improve-server-performance%2F&amp;linkname=PostgreSQL%3A%20Disable%20Non-Durable%20parameters%20and%20Improve%20Server%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%2F2019%2F06%2Fpostgresql-disable-non-durable-parameters-and-improve-server-performance%2F&amp;linkname=PostgreSQL%3A%20Disable%20Non-Durable%20parameters%20and%20Improve%20Server%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%2F2019%2F06%2Fpostgresql-disable-non-durable-parameters-and-improve-server-performance%2F&amp;linkname=PostgreSQL%3A%20Disable%20Non-Durable%20parameters%20and%20Improve%20Server%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%2F2019%2F06%2Fpostgresql-disable-non-durable-parameters-and-improve-server-performance%2F&amp;linkname=PostgreSQL%3A%20Disable%20Non-Durable%20parameters%20and%20Improve%20Server%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%2F2019%2F06%2Fpostgresql-disable-non-durable-parameters-and-improve-server-performance%2F&amp;linkname=PostgreSQL%3A%20Disable%20Non-Durable%20parameters%20and%20Improve%20Server%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%2F2019%2F06%2Fpostgresql-disable-non-durable-parameters-and-improve-server-performance%2F&#038;title=PostgreSQL%3A%20Disable%20Non-Durable%20parameters%20and%20Improve%20Server%20Performance" data-a2a-url="https://www.dbrnd.com/2019/06/postgresql-disable-non-durable-parameters-and-improve-server-performance/" data-a2a-title="PostgreSQL: Disable Non-Durable parameters and Improve Server Performance"></a></p><blockquote><p>
<strong>Important notice: Never try in your Production or any other Live server. This post is only ad-hoc and test server. </strong></p></blockquote>
<p>Data Durability is an important part of Database ACID property. In this post, I am sharing few parameters which we can disable for achieving good performance of PostgreSQL Database Server.</p>
<p>We should disable Non-Durable parameters on our test server where we need only POC related work, and if your system doesn&#8217;t require any guarantee of data, then you can disable. </p>
<p><strong>Why disabling the Non-Durable parameters?</strong></p>
<blockquote><p>PostgreSQL guarantees the full durability of data even if the server crashes or loses power.<br />
But committing every single transaction in datafile and log file is also extra overhead on the database server.<br />
So simple, just disable that parameter for achieving good performance.
 </p></blockquote>
<blockquote class="wp-embedded-content" data-secret="T6TwASV5Ev"><p><a href="https://www.dbrnd.com/2015/05/acid-properties-in-database-system/">ACID Properties in Database System (Atomicity, Consistency, Isolation, Durability)</a></p></blockquote>
<p><iframe class="wp-embedded-content" sandbox="allow-scripts" security="restricted"  src="https://www.dbrnd.com/2015/05/acid-properties-in-database-system/embed/#?secret=T6TwASV5Ev" data-secret="T6TwASV5Ev" width="600" height="338" title="&#8220;ACID Properties in Database System (Atomicity, Consistency, Isolation, Durability)&#8221; &#8212; Database Research &amp; Development" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe></p>
<p><strong>Below are parameters:</strong></p>
<blockquote><p>fsync: Turn off &#8211; no need to flush data to disk </p>
<p>synchronous_commit: Turn off &#8211; not need to write to disk on every commit</p>
<p>full_page_writes: Turn off &#8211; no need to guard against partial page writes</p>
<p>max_wal_size: Increase &#8211; reduces the frequency of checkpoints</p>
<p>checkpoint_timeout: Increase &#8211; reduces the frequency of checkpoints</p></blockquote>
]]></content:encoded>
					
					<wfw:commentRss>https://www.dbrnd.com/2019/06/postgresql-disable-non-durable-parameters-and-improve-server-performance/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>PostgreSQL: How to remove accents (diacritic signs) from lexemes</title>
		<link>https://www.dbrnd.com/2019/05/postgresql-how-to-remove-accents-diacritic-signs-from-lexemes/</link>
					<comments>https://www.dbrnd.com/2019/05/postgresql-how-to-remove-accents-diacritic-signs-from-lexemes/#respond</comments>
		
		<dc:creator><![CDATA[Anvesh Patel]]></dc:creator>
		<pubDate>Mon, 13 May 2019 16:16:20 +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[diacritic signs]]></category>
		<category><![CDATA[lexemes]]></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 Monitoring]]></category>
		<category><![CDATA[PostgreSQL Performance Tuning]]></category>
		<category><![CDATA[PostgreSQL Programming]]></category>
		<category><![CDATA[PostgreSQL Tips and Tricks]]></category>
		<category><![CDATA[unaccent]]></category>
		<guid isPermaLink="false">https://www.dbrnd.com/?p=7018</guid>

					<description><![CDATA[In this post, I am sharing the use of &#8220;unaccent&#8221; extension of PostgreSQL. Use unaccent, for removing diacritic signs from the string and convert into the valid character as per the specified collation. When we are importing data from different types of datasets, we can find diacritic signs in the data. We can use unaccent() [&#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%2F2019%2F05%2Fpostgresql-how-to-remove-accents-diacritic-signs-from-lexemes%2F&amp;linkname=PostgreSQL%3A%20How%20to%20remove%20accents%20%28diacritic%20signs%29%20from%20lexemes" 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%2F05%2Fpostgresql-how-to-remove-accents-diacritic-signs-from-lexemes%2F&amp;linkname=PostgreSQL%3A%20How%20to%20remove%20accents%20%28diacritic%20signs%29%20from%20lexemes" 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%2F05%2Fpostgresql-how-to-remove-accents-diacritic-signs-from-lexemes%2F&amp;linkname=PostgreSQL%3A%20How%20to%20remove%20accents%20%28diacritic%20signs%29%20from%20lexemes" 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%2F05%2Fpostgresql-how-to-remove-accents-diacritic-signs-from-lexemes%2F&amp;linkname=PostgreSQL%3A%20How%20to%20remove%20accents%20%28diacritic%20signs%29%20from%20lexemes" 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%2F05%2Fpostgresql-how-to-remove-accents-diacritic-signs-from-lexemes%2F&amp;linkname=PostgreSQL%3A%20How%20to%20remove%20accents%20%28diacritic%20signs%29%20from%20lexemes" 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%2F05%2Fpostgresql-how-to-remove-accents-diacritic-signs-from-lexemes%2F&amp;linkname=PostgreSQL%3A%20How%20to%20remove%20accents%20%28diacritic%20signs%29%20from%20lexemes" 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%2F05%2Fpostgresql-how-to-remove-accents-diacritic-signs-from-lexemes%2F&#038;title=PostgreSQL%3A%20How%20to%20remove%20accents%20%28diacritic%20signs%29%20from%20lexemes" data-a2a-url="https://www.dbrnd.com/2019/05/postgresql-how-to-remove-accents-diacritic-signs-from-lexemes/" data-a2a-title="PostgreSQL: How to remove accents (diacritic signs) from lexemes"></a></p><p>In this post, I am sharing the use of &#8220;unaccent&#8221; extension of PostgreSQL. </p>
<p>Use unaccent, for removing diacritic signs from the string and convert into the valid character as per the specified collation.</p>
<p>When we are importing data from different types of datasets, we can find diacritic signs in the data. We can use unaccent() for removing those signs. </p>
<p><strong>Check below demonstration:</strong></p>
<p><strong>Create an extension:</strong></p>
<pre class="crayon-plain-tag">CREATE EXTENSION unaccent;</pre> </p>
<p><strong>Use unaccent():</strong></p>
<pre class="crayon-plain-tag">SELECT unaccent('ô ã À Æ ß Ä');</pre> </p>
<p><strong>Result:</strong></p>
<pre class="crayon-plain-tag">unaccent
------------------
'o a A AE ss A'</pre> </p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.dbrnd.com/2019/05/postgresql-how-to-remove-accents-diacritic-signs-from-lexemes/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>PostgreSQL: Find Factorial, Absolute, Negation value</title>
		<link>https://www.dbrnd.com/2019/04/postgresql-find-factorial-absolute-negation-value/</link>
					<comments>https://www.dbrnd.com/2019/04/postgresql-find-factorial-absolute-negation-value/#respond</comments>
		
		<dc:creator><![CDATA[Anvesh Patel]]></dc:creator>
		<pubDate>Mon, 15 Apr 2019 18:34:07 +0000</pubDate>
				<category><![CDATA[PostgreSQL]]></category>
		<category><![CDATA[absolute value]]></category>
		<category><![CDATA[Anvesh Patel]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[database research and development]]></category>
		<category><![CDATA[dbrnd]]></category>
		<category><![CDATA[factorial]]></category>
		<category><![CDATA[negation value]]></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 Monitoring]]></category>
		<category><![CDATA[PostgreSQL Performance Tuning]]></category>
		<category><![CDATA[PostgreSQL Programming]]></category>
		<category><![CDATA[PostgreSQL Tips and Tricks]]></category>
		<guid isPermaLink="false">https://www.dbrnd.com/?p=6979</guid>

					<description><![CDATA[In this post, I am sharing few mathematical operators for finding factorial, absolute and negation value in PostgreSQL. I was reading the official the official page of PostgreSQL and found few interesting operators which we can use for the mathematical purpose. Check below examples: ! operator for factorial: [crayon-6ab4c25c20395009956841/] @ operator for absolute: [crayon-6ab4c25c20399607081493/] ~ [&#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%2F2019%2F04%2Fpostgresql-find-factorial-absolute-negation-value%2F&amp;linkname=PostgreSQL%3A%20Find%20Factorial%2C%20Absolute%2C%20Negation%20value" 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%2F04%2Fpostgresql-find-factorial-absolute-negation-value%2F&amp;linkname=PostgreSQL%3A%20Find%20Factorial%2C%20Absolute%2C%20Negation%20value" 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%2F04%2Fpostgresql-find-factorial-absolute-negation-value%2F&amp;linkname=PostgreSQL%3A%20Find%20Factorial%2C%20Absolute%2C%20Negation%20value" 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%2F04%2Fpostgresql-find-factorial-absolute-negation-value%2F&amp;linkname=PostgreSQL%3A%20Find%20Factorial%2C%20Absolute%2C%20Negation%20value" 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%2F04%2Fpostgresql-find-factorial-absolute-negation-value%2F&amp;linkname=PostgreSQL%3A%20Find%20Factorial%2C%20Absolute%2C%20Negation%20value" 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%2F04%2Fpostgresql-find-factorial-absolute-negation-value%2F&amp;linkname=PostgreSQL%3A%20Find%20Factorial%2C%20Absolute%2C%20Negation%20value" 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%2F04%2Fpostgresql-find-factorial-absolute-negation-value%2F&#038;title=PostgreSQL%3A%20Find%20Factorial%2C%20Absolute%2C%20Negation%20value" data-a2a-url="https://www.dbrnd.com/2019/04/postgresql-find-factorial-absolute-negation-value/" data-a2a-title="PostgreSQL: Find Factorial, Absolute, Negation value"></a></p><p>In this post, I am sharing few mathematical operators for finding factorial, absolute and negation value in PostgreSQL. </p>
<p>I was reading the official the official page of PostgreSQL and found few interesting operators which we can use for the mathematical purpose.</p>
<p><strong>Check below examples:</strong></p>
<p><strong>! operator for factorial:</strong></p>
<pre class="crayon-plain-tag">SELECT 8 ! AS "8 factorial";

8 factorial
------------
'40320'</pre> </p>
<p><strong>@ operator for absolute:</strong></p>
<pre class="crayon-plain-tag">SELECT @ '-8.8' AS "absolute value";

absolute values
------------
'40320'</pre> </p>
<p><strong>~ operator for negation:</strong></p>
<pre class="crayon-plain-tag">SELECT ~ CAST('16' AS int8) AS "negation value";

negation value
---------------
'-17'</pre> </p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.dbrnd.com/2019/04/postgresql-find-factorial-absolute-negation-value/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>PostgreSQL: Script to convert User to Super User</title>
		<link>https://www.dbrnd.com/2019/03/postgresql-script-to-convert-user-to-super-user/</link>
					<comments>https://www.dbrnd.com/2019/03/postgresql-script-to-convert-user-to-super-user/#respond</comments>
		
		<dc:creator><![CDATA[Anvesh Patel]]></dc:creator>
		<pubDate>Mon, 25 Mar 2019 16:16:47 +0000</pubDate>
				<category><![CDATA[PostgreSQL]]></category>
		<category><![CDATA[PostgreSQL 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[plpgsql]]></category>
		<category><![CDATA[Postgres Query]]></category>
		<category><![CDATA[postgresql]]></category>
		<category><![CDATA[PostgreSQL Administrator]]></category>
		<category><![CDATA[PostgreSQL Error]]></category>
		<category><![CDATA[PostgreSQL Monitoring]]></category>
		<category><![CDATA[PostgreSQL Performance Tuning]]></category>
		<category><![CDATA[PostgreSQL Programming]]></category>
		<category><![CDATA[PostgreSQL Tips and Tricks]]></category>
		<category><![CDATA[super user]]></category>
		<category><![CDATA[User Permission]]></category>
		<guid isPermaLink="false">https://www.dbrnd.com/?p=7322</guid>

					<description><![CDATA[In this post, I am sharing a script for transforming normal DB user to Super User in PostgreSQL. The Super User is the admin user and it has all kind of access to PostgreSQL Server. We can create multiple superusers in PostgreSQL. I need this kind of handy commands/scripts because when any new dba join [&#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%2F2019%2F03%2Fpostgresql-script-to-convert-user-to-super-user%2F&amp;linkname=PostgreSQL%3A%20Script%20to%20convert%20User%20to%20Super%20User" 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%2F03%2Fpostgresql-script-to-convert-user-to-super-user%2F&amp;linkname=PostgreSQL%3A%20Script%20to%20convert%20User%20to%20Super%20User" 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%2F03%2Fpostgresql-script-to-convert-user-to-super-user%2F&amp;linkname=PostgreSQL%3A%20Script%20to%20convert%20User%20to%20Super%20User" 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%2F03%2Fpostgresql-script-to-convert-user-to-super-user%2F&amp;linkname=PostgreSQL%3A%20Script%20to%20convert%20User%20to%20Super%20User" 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%2F03%2Fpostgresql-script-to-convert-user-to-super-user%2F&amp;linkname=PostgreSQL%3A%20Script%20to%20convert%20User%20to%20Super%20User" 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%2F03%2Fpostgresql-script-to-convert-user-to-super-user%2F&amp;linkname=PostgreSQL%3A%20Script%20to%20convert%20User%20to%20Super%20User" 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%2F03%2Fpostgresql-script-to-convert-user-to-super-user%2F&#038;title=PostgreSQL%3A%20Script%20to%20convert%20User%20to%20Super%20User" data-a2a-url="https://www.dbrnd.com/2019/03/postgresql-script-to-convert-user-to-super-user/" data-a2a-title="PostgreSQL: Script to convert User to Super User"></a></p><p>In this post, I am sharing a script for transforming normal DB user to Super User in PostgreSQL. </p>
<p>The Super User is the admin user and it has all kind of access to PostgreSQL Server. We can create multiple superusers in PostgreSQL. </p>
<p>I need this kind of handy commands/scripts because when any new dba join the team, giving basic permission of database and later the same user requires superuser permission. </p>
<p><strong>Convert a user into Super User:</strong></p>
<pre class="crayon-plain-tag">ALTER USER user_name WITH SUPERUSER;</pre> </p>
<p><strong>Revoke Super User Permission:</strong></p>
<pre class="crayon-plain-tag">ALTER USER user_name WITH NOSUPERUSER;</pre> </p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.dbrnd.com/2019/03/postgresql-script-to-convert-user-to-super-user/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>PostgreSQL: Bash Shell Script to execute psql command in UNIX / LINUX</title>
		<link>https://www.dbrnd.com/2019/03/postgresql-bash-shell-script-to-execute-psql-command-in-unix-linux/</link>
					<comments>https://www.dbrnd.com/2019/03/postgresql-bash-shell-script-to-execute-psql-command-in-unix-linux/#comments</comments>
		
		<dc:creator><![CDATA[Anvesh Patel]]></dc:creator>
		<pubDate>Mon, 04 Mar 2019 16:16:25 +0000</pubDate>
				<category><![CDATA[Bash Shell Script]]></category>
		<category><![CDATA[PostgreSQL]]></category>
		<category><![CDATA[PostgreSQL DBA Script]]></category>
		<category><![CDATA[Anvesh Patel]]></category>
		<category><![CDATA[Bash shell script]]></category>
		<category><![CDATA[chmod]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[database research and development]]></category>
		<category><![CDATA[dbrnd]]></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 Monitoring]]></category>
		<category><![CDATA[PostgreSQL Performance Tuning]]></category>
		<category><![CDATA[PostgreSQL Programming]]></category>
		<category><![CDATA[PostgreSQL Tips and Tricks]]></category>
		<category><![CDATA[psql]]></category>
		<category><![CDATA[vi editor]]></category>
		<guid isPermaLink="false">https://www.dbrnd.com/?p=4374</guid>

					<description><![CDATA[As per the en.wikibooks.org: Bash is a &#8220;Unix shell&#8221;: a command-line interface for interacting with the operating system. It has the ability to run an entire script of commands, known as a &#8220;Bash shell script&#8221;. I recently started to create UNIX / LINUX Bash Shell script for enhancing my PostgreSQL DBA Work. You can create [&#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%2F2019%2F03%2Fpostgresql-bash-shell-script-to-execute-psql-command-in-unix-linux%2F&amp;linkname=PostgreSQL%3A%20Bash%20Shell%20Script%20to%20execute%20psql%20command%20in%20UNIX%20%2F%20LINUX" 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%2F03%2Fpostgresql-bash-shell-script-to-execute-psql-command-in-unix-linux%2F&amp;linkname=PostgreSQL%3A%20Bash%20Shell%20Script%20to%20execute%20psql%20command%20in%20UNIX%20%2F%20LINUX" 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%2F03%2Fpostgresql-bash-shell-script-to-execute-psql-command-in-unix-linux%2F&amp;linkname=PostgreSQL%3A%20Bash%20Shell%20Script%20to%20execute%20psql%20command%20in%20UNIX%20%2F%20LINUX" 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%2F03%2Fpostgresql-bash-shell-script-to-execute-psql-command-in-unix-linux%2F&amp;linkname=PostgreSQL%3A%20Bash%20Shell%20Script%20to%20execute%20psql%20command%20in%20UNIX%20%2F%20LINUX" 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%2F03%2Fpostgresql-bash-shell-script-to-execute-psql-command-in-unix-linux%2F&amp;linkname=PostgreSQL%3A%20Bash%20Shell%20Script%20to%20execute%20psql%20command%20in%20UNIX%20%2F%20LINUX" 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%2F03%2Fpostgresql-bash-shell-script-to-execute-psql-command-in-unix-linux%2F&amp;linkname=PostgreSQL%3A%20Bash%20Shell%20Script%20to%20execute%20psql%20command%20in%20UNIX%20%2F%20LINUX" 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%2F03%2Fpostgresql-bash-shell-script-to-execute-psql-command-in-unix-linux%2F&#038;title=PostgreSQL%3A%20Bash%20Shell%20Script%20to%20execute%20psql%20command%20in%20UNIX%20%2F%20LINUX" data-a2a-url="https://www.dbrnd.com/2019/03/postgresql-bash-shell-script-to-execute-psql-command-in-unix-linux/" data-a2a-title="PostgreSQL: Bash Shell Script to execute psql command in UNIX / LINUX"></a></p><p>As per the en.wikibooks.org:</p>
<blockquote><p>Bash is a &#8220;Unix shell&#8221;: a command-line interface for interacting with the operating system. It has the ability to run an entire script of commands, known as a &#8220;Bash shell script&#8221;.</p></blockquote>
<p>I recently started to create UNIX / LINUX Bash Shell script for enhancing my PostgreSQL DBA Work. You can create a Bash shell script and can connect PostgreSQL using psql. </p>
<p>In this post, I am sharing a sample bash shell script to execute psql commands. </p>
<p><strong>Open a new file in vi editor:</strong></p>
<pre class="crayon-plain-tag">[root@dbrnd anvesh]$ vi helloworld.bash</pre> </p>
<p><strong>Press [i] key to get an insert prompt:</strong></p>
<p><strong>Copy below sample Bash Shell Script and Paste into vi editor:</strong></p>
<pre class="crayon-plain-tag">#!/bin/bash

###################################################
# First Bash Shell script to execute psql command 
###################################################

#Set the value of variable
database="database_name"

#Execute few psql commands: 
#Note: you can also add -h hostname -U username in the below commands. 

psql -d $database -c "CREATE TABLE public.tbl_students(rno integer, name character varying)"
psql -d $database -c "INSERT INTO public.tbl_students VALUES (1,'Anvesh'),(2,'Neevan'),(3,'Roy'),(4,'Martin'),(5,'Jenny')"
psql -d $database -c "SELECT *FROM public.tbl_students"

#Assign table count to variable
TableCount=$(psql -d $database -t -c "select count(1) from public.tbl_students")

#Print the value of variable
echo "Total table records count....:"$TableCount</pre> </p>
<p><strong>Press [Esc] key to get a command prompt and execute below command:</strong><br />
To save and exit vi editor.</p>
<pre class="crayon-plain-tag">:wq</pre> </p>
<p><strong>Give permission to the file:</strong></p>
<pre class="crayon-plain-tag">[root@dbrnd anvesh]$ chmod +x helloworld.bash</pre> </p>
<p><strong>Execute this file:</strong></p>
<pre class="crayon-plain-tag">[root@dbrnd anvesh]$ ./helloworld.bash</pre> </p>
<p><strong>You can find below result:</strong></p>
<pre class="crayon-plain-tag">rno |  name
-----+--------
   1 | Anvesh
   5 | Jenny
   2 | Neevan
   3 | Roy
   4 | Martin
(5 rows)

Total table records count....: 5</pre> </p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.dbrnd.com/2019/03/postgresql-bash-shell-script-to-execute-psql-command-in-unix-linux/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
			</item>
		<item>
		<title>PostgreSQL: Don&#8217;t take backup until your Database is changed</title>
		<link>https://www.dbrnd.com/2019/02/postgresql-dont-take-backup-until-your-database-is-changed-check-pg_stat_database-tuple/</link>
					<comments>https://www.dbrnd.com/2019/02/postgresql-dont-take-backup-until-your-database-is-changed-check-pg_stat_database-tuple/#respond</comments>
		
		<dc:creator><![CDATA[Anvesh Patel]]></dc:creator>
		<pubDate>Mon, 25 Feb 2019 16:16:38 +0000</pubDate>
				<category><![CDATA[PostgreSQL]]></category>
		<category><![CDATA[Anvesh Patel]]></category>
		<category><![CDATA[backup]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[database research and development]]></category>
		<category><![CDATA[dbrnd]]></category>
		<category><![CDATA[pg_stat_database]]></category>
		<category><![CDATA[pg_stat_reset]]></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 Monitoring]]></category>
		<category><![CDATA[PostgreSQL Performance Tuning]]></category>
		<category><![CDATA[PostgreSQL Programming]]></category>
		<category><![CDATA[PostgreSQL Tips and Tricks]]></category>
		<category><![CDATA[tup_inserted]]></category>
		<guid isPermaLink="false">https://www.dbrnd.com/?p=4442</guid>

					<description><![CDATA[In this post, I am sharing an important tip for PostgreSQL DBAs. I recently started work with a new PostgreSQL Client. They have total 326 databases in their PostgreSQL Server. They are taking full backup for all the database and this process is taking around total 7 hours. When I looked this, my first step [&#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%2F2019%2F02%2Fpostgresql-dont-take-backup-until-your-database-is-changed-check-pg_stat_database-tuple%2F&amp;linkname=PostgreSQL%3A%20Don%E2%80%99t%20take%20backup%20until%20your%20Database%20is%20changed" 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%2Fpostgresql-dont-take-backup-until-your-database-is-changed-check-pg_stat_database-tuple%2F&amp;linkname=PostgreSQL%3A%20Don%E2%80%99t%20take%20backup%20until%20your%20Database%20is%20changed" 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%2Fpostgresql-dont-take-backup-until-your-database-is-changed-check-pg_stat_database-tuple%2F&amp;linkname=PostgreSQL%3A%20Don%E2%80%99t%20take%20backup%20until%20your%20Database%20is%20changed" 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%2Fpostgresql-dont-take-backup-until-your-database-is-changed-check-pg_stat_database-tuple%2F&amp;linkname=PostgreSQL%3A%20Don%E2%80%99t%20take%20backup%20until%20your%20Database%20is%20changed" 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%2Fpostgresql-dont-take-backup-until-your-database-is-changed-check-pg_stat_database-tuple%2F&amp;linkname=PostgreSQL%3A%20Don%E2%80%99t%20take%20backup%20until%20your%20Database%20is%20changed" 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%2Fpostgresql-dont-take-backup-until-your-database-is-changed-check-pg_stat_database-tuple%2F&amp;linkname=PostgreSQL%3A%20Don%E2%80%99t%20take%20backup%20until%20your%20Database%20is%20changed" 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%2Fpostgresql-dont-take-backup-until-your-database-is-changed-check-pg_stat_database-tuple%2F&#038;title=PostgreSQL%3A%20Don%E2%80%99t%20take%20backup%20until%20your%20Database%20is%20changed" data-a2a-url="https://www.dbrnd.com/2019/02/postgresql-dont-take-backup-until-your-database-is-changed-check-pg_stat_database-tuple/" data-a2a-title="PostgreSQL: Don’t take backup until your Database is changed"></a></p><p>In this post, I am sharing an important tip for PostgreSQL DBAs. </p>
<p>I recently started work with a new PostgreSQL Client. They have total 326 databases in their PostgreSQL Server. They are taking full backup for all the database and this process is taking around total 7 hours. </p>
<p>When I looked this, my first step was to find database statistics. I have found 25% of databases are not being updated frequently. </p>
<blockquote><p>I added one additional check in a backup process like &#8220;skip the backup for those databases which have not been changed for any operations (DDL or DML operation)&#8221;.<br />
After this check, the backup process is taking around total 5 hours to complete the job.</p></blockquote>
<blockquote><p>Using pg_stat_database, you can check the stats of database and can compare the value for tuple columns with the old value. If you found any changes, your database has been changed.</p></blockquote>
<p>If any of your DBA reset the PostgreSQL database statistics using something like pg_stat_reset, you have to add some more extra logic to understand the difference between statistics. </p>
<p>Below is a sample demonstration:<br />
<strong>Create a backup table to store DatabaseStats:</strong></p>
<pre class="crayon-plain-tag">CREATE TABLE public.tbl_DatabaseStats AS
SELECT 
	datname
	,tup_inserted
	,tup_updated
	,tup_deleted	
FROM pg_stat_database;</pre> </p>
<p><strong>Perform few DDLs and DMLs actions:</strong></p>
<pre class="crayon-plain-tag">CREATE TABLE public.tbl_Students(rno int, name character varying);
INSERT INTO public.tbl_Students VALUES(1,'Anvesh');
CREATE TABLE public.tbl_Test88(id int);</pre> </p>
<p><strong>Compare the result of below two queries:</strong><br />
If you find differences on any of the columns of your Database, your database stats has been changed and you should take the backup of your database.</p>
<pre class="crayon-plain-tag">SELECT 
	datname
	,tup_inserted
	,tup_updated
	,tup_deleted	
FROM pg_stat_database;

SELECT *FROM public.tbl_DatabaseStats;</pre> </p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.dbrnd.com/2019/02/postgresql-dont-take-backup-until-your-database-is-changed-check-pg_stat_database-tuple/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>PostgreSQL: What is IMMUTABLE, STABLE, VOLATILE and COST of Function</title>
		<link>https://www.dbrnd.com/2019/02/postgresql-what-is-immutable-stable-volatile-and-cost-of-function/</link>
					<comments>https://www.dbrnd.com/2019/02/postgresql-what-is-immutable-stable-volatile-and-cost-of-function/#respond</comments>
		
		<dc:creator><![CDATA[Anvesh Patel]]></dc:creator>
		<pubDate>Mon, 18 Feb 2019 16:16:06 +0000</pubDate>
				<category><![CDATA[PostgreSQL]]></category>
		<category><![CDATA[Anvesh Patel]]></category>
		<category><![CDATA[COST]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[database research and development]]></category>
		<category><![CDATA[dbrnd]]></category>
		<category><![CDATA[Function Attribute]]></category>
		<category><![CDATA[IMMUTABLE]]></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 Monitoring]]></category>
		<category><![CDATA[PostgreSQL Performance Tuning]]></category>
		<category><![CDATA[PostgreSQL Programming]]></category>
		<category><![CDATA[PostgreSQL Tips and Tricks]]></category>
		<category><![CDATA[STABLE]]></category>
		<category><![CDATA[VOLATILE]]></category>
		<guid isPermaLink="false">https://www.dbrnd.com/?p=4996</guid>

					<description><![CDATA[While creating a function, You can define the attributes like IMMUTABLE, STABLE, VOLATILE and COST. These attributes inform the query optimizer about the behaviour of the function. IMMUTABLE: It indicates that the function cannot modify the database and always returns the same result when given the same argument values; that is, it does not do [&#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%2F2019%2F02%2Fpostgresql-what-is-immutable-stable-volatile-and-cost-of-function%2F&amp;linkname=PostgreSQL%3A%20What%20is%20IMMUTABLE%2C%20STABLE%2C%20VOLATILE%20and%20COST%20of%20Function" 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%2Fpostgresql-what-is-immutable-stable-volatile-and-cost-of-function%2F&amp;linkname=PostgreSQL%3A%20What%20is%20IMMUTABLE%2C%20STABLE%2C%20VOLATILE%20and%20COST%20of%20Function" 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%2Fpostgresql-what-is-immutable-stable-volatile-and-cost-of-function%2F&amp;linkname=PostgreSQL%3A%20What%20is%20IMMUTABLE%2C%20STABLE%2C%20VOLATILE%20and%20COST%20of%20Function" 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%2Fpostgresql-what-is-immutable-stable-volatile-and-cost-of-function%2F&amp;linkname=PostgreSQL%3A%20What%20is%20IMMUTABLE%2C%20STABLE%2C%20VOLATILE%20and%20COST%20of%20Function" 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%2Fpostgresql-what-is-immutable-stable-volatile-and-cost-of-function%2F&amp;linkname=PostgreSQL%3A%20What%20is%20IMMUTABLE%2C%20STABLE%2C%20VOLATILE%20and%20COST%20of%20Function" 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%2Fpostgresql-what-is-immutable-stable-volatile-and-cost-of-function%2F&amp;linkname=PostgreSQL%3A%20What%20is%20IMMUTABLE%2C%20STABLE%2C%20VOLATILE%20and%20COST%20of%20Function" 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%2Fpostgresql-what-is-immutable-stable-volatile-and-cost-of-function%2F&#038;title=PostgreSQL%3A%20What%20is%20IMMUTABLE%2C%20STABLE%2C%20VOLATILE%20and%20COST%20of%20Function" data-a2a-url="https://www.dbrnd.com/2019/02/postgresql-what-is-immutable-stable-volatile-and-cost-of-function/" data-a2a-title="PostgreSQL: What is IMMUTABLE, STABLE, VOLATILE and COST of Function"></a></p><p>While creating a function, You can define the attributes like IMMUTABLE, STABLE, VOLATILE and COST. These attributes inform the query optimizer about the behaviour of the function.</p>
<blockquote><p><strong>IMMUTABLE:</strong> It indicates that the function cannot modify the database and always returns the same result when given the same argument values; that is, it does not do database lookups or otherwise use information not directly present in its argument list.</p></blockquote>
<blockquote><p><strong>STABLE:</strong> It indicates that the function cannot modify the database, and that within a single table scan it will consistently return the same result for the same argument values, but that its result could change across SQL statements. This is the appropriate selection for functions whose results depend on database lookups, parameter variables (such as the current time zone), etc.</p></blockquote>
<blockquote><p><strong>VOLATILE:</strong> It indicates that the function value can change even within a single table scan so that no optimizations can make.</p></blockquote>
<blockquote><p><strong>COST:</strong> It declares the cost per row of the result, which is used by the query planner to find the cheapest plan. The default is COST 100. COST measured in CPU cycles. A higher COST number means more costly. A COST will give the planner a better idea of which strategy to use.</p></blockquote>
<pre class="crayon-plain-tag">CREATE FUNCTION fn_test()
  RETURNS as
$$
declare
	-- declare variables...
begin	
	-- do operations...	
end
$$ language plpgsql VOLATILE
COST 10000;</pre> </p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.dbrnd.com/2019/02/postgresql-what-is-immutable-stable-volatile-and-cost-of-function/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>PostgreSQL: Optimize the Function by defining Volatility Classification</title>
		<link>https://www.dbrnd.com/2018/12/postgresql-optimize-the-function-by-defining-volatility-classification-immutable-volatile-stable/</link>
					<comments>https://www.dbrnd.com/2018/12/postgresql-optimize-the-function-by-defining-volatility-classification-immutable-volatile-stable/#respond</comments>
		
		<dc:creator><![CDATA[Anvesh Patel]]></dc:creator>
		<pubDate>Mon, 31 Dec 2018 16:16:24 +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[Function Optimization]]></category>
		<category><![CDATA[Function Volatility]]></category>
		<category><![CDATA[IMMUTABLE]]></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 Monitoring]]></category>
		<category><![CDATA[PostgreSQL Performance Tuning]]></category>
		<category><![CDATA[PostgreSQL Programming]]></category>
		<category><![CDATA[PostgreSQL Tips and Tricks]]></category>
		<category><![CDATA[STABLE]]></category>
		<category><![CDATA[VOLATILE]]></category>
		<guid isPermaLink="false">https://www.dbrnd.com/?p=7273</guid>

					<description><![CDATA[<div><img width="679" height="186" src="https://www.dbrnd.com/wp-content/uploads/2018/03/optimize-function-679x186.jpg" class="attachment-post-image size-post-image wp-post-image" alt="" decoding="async" fetchpriority="high" srcset="https://www.dbrnd.com/wp-content/uploads/2018/03/optimize-function-679x186.jpg 679w, https://www.dbrnd.com/wp-content/uploads/2018/03/optimize-function-1030x282.jpg 1030w, https://www.dbrnd.com/wp-content/uploads/2018/03/optimize-function-850x233.jpg 850w, https://www.dbrnd.com/wp-content/uploads/2018/03/optimize-function-1700x466.jpg 1700w, https://www.dbrnd.com/wp-content/uploads/2018/03/optimize-function-1358x372.jpg 1358w, https://www.dbrnd.com/wp-content/uploads/2018/03/optimize-function.jpg 2000w" sizes="(max-width: 679px) 100vw, 679px" /></div>This is an important article for PostgreSQL Developer because many of the database developers don&#8217;t know about the PostgreSQL Function Volatility. Every function has a volatility classification, with the possibilities being VOLATILE, STABLE, or IMMUTABLE. VOLATILE is the default. In this post, I am not going to write 1000 words on it. Because I believe [&#8230;]]]></description>
										<content:encoded><![CDATA[<div><img width="679" height="186" src="https://www.dbrnd.com/wp-content/uploads/2018/03/optimize-function-679x186.jpg" class="attachment-post-image size-post-image wp-post-image" alt="" decoding="async" loading="lazy" srcset="https://www.dbrnd.com/wp-content/uploads/2018/03/optimize-function-679x186.jpg 679w, https://www.dbrnd.com/wp-content/uploads/2018/03/optimize-function-1030x282.jpg 1030w, https://www.dbrnd.com/wp-content/uploads/2018/03/optimize-function-850x233.jpg 850w, https://www.dbrnd.com/wp-content/uploads/2018/03/optimize-function-1700x466.jpg 1700w, https://www.dbrnd.com/wp-content/uploads/2018/03/optimize-function-1358x372.jpg 1358w, https://www.dbrnd.com/wp-content/uploads/2018/03/optimize-function.jpg 2000w" 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%2F12%2Fpostgresql-optimize-the-function-by-defining-volatility-classification-immutable-volatile-stable%2F&amp;linkname=PostgreSQL%3A%20Optimize%20the%20Function%20by%20defining%20Volatility%20Classification" 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%2F12%2Fpostgresql-optimize-the-function-by-defining-volatility-classification-immutable-volatile-stable%2F&amp;linkname=PostgreSQL%3A%20Optimize%20the%20Function%20by%20defining%20Volatility%20Classification" 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%2F12%2Fpostgresql-optimize-the-function-by-defining-volatility-classification-immutable-volatile-stable%2F&amp;linkname=PostgreSQL%3A%20Optimize%20the%20Function%20by%20defining%20Volatility%20Classification" 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%2F12%2Fpostgresql-optimize-the-function-by-defining-volatility-classification-immutable-volatile-stable%2F&amp;linkname=PostgreSQL%3A%20Optimize%20the%20Function%20by%20defining%20Volatility%20Classification" 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%2F12%2Fpostgresql-optimize-the-function-by-defining-volatility-classification-immutable-volatile-stable%2F&amp;linkname=PostgreSQL%3A%20Optimize%20the%20Function%20by%20defining%20Volatility%20Classification" 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%2F12%2Fpostgresql-optimize-the-function-by-defining-volatility-classification-immutable-volatile-stable%2F&amp;linkname=PostgreSQL%3A%20Optimize%20the%20Function%20by%20defining%20Volatility%20Classification" 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%2F12%2Fpostgresql-optimize-the-function-by-defining-volatility-classification-immutable-volatile-stable%2F&#038;title=PostgreSQL%3A%20Optimize%20the%20Function%20by%20defining%20Volatility%20Classification" data-a2a-url="https://www.dbrnd.com/2018/12/postgresql-optimize-the-function-by-defining-volatility-classification-immutable-volatile-stable/" data-a2a-title="PostgreSQL: Optimize the Function by defining Volatility Classification"></a></p><p>This is an important article for PostgreSQL Developer because many of the database developers don&#8217;t know about the PostgreSQL Function Volatility. </p>
<p>Every function has a volatility classification, with the possibilities being VOLATILE, STABLE, or IMMUTABLE. VOLATILE is the default.</p>
<blockquote><p>In this post, I am not going to write 1000 words on it. Because I believe in practical so sharing a good practical example here.<br />
But you must read about the PostgreSQL Function Volatility from <a href="https://www.postgresql.org/docs/8.1/static/xfunc-volatility.html" rel="noopener" target="_blank">this</a> official page. </p></blockquote>
<p>Check the below practical example and you will get to know that how VOLATILE function is choosing the bad Query Execution Plan. </p>
<p><strong>Create a sample function:</strong></p>
<pre class="crayon-plain-tag">CREATE OR REPLACE FUNCTION fn_getvalues(int, int)
RETURNS int
AS
$$
  BEGIN
       RETURN 
       	CASE WHEN $1 = $2 THEN $1 ELSE $2 END;
  END;
$$ LANGUAGE 'plpgsql';</pre> </p>
<p><strong>Check the result of sample function:</strong></p>
<pre class="crayon-plain-tag">SELECT * FROM fn_getvalues(50,80);

fn_getvalues
-----------------
80</pre> </p>
<p><strong>Create a sample table with data:</strong></p>
<pre class="crayon-plain-tag">CREATE TABLE tbl_ItemTransactions 
 (
     TranID SERIAL
     ,TransactionDate TIMESTAMPTZ
     ,TransactionName TEXT
 );

CREATE INDEX idx_TranID ON tbl_ItemTransactions (TranID);
 
INSERT INTO tbl_ItemTransactions 
(TransactionDate, TransactionName)
SELECT x, 'dbrnd' 
FROM generate_series('2017-01-01 00:00:00'::timestamptz, '2018-01-31 00:00:00'::timestamptz,'50 seconds'::interval) a(x);</pre> </p>
<p><strong>Check the execution plan for below query:</strong><br />
You can find &#8216;Index Scan&#8217; because the huge table and index applied properly. </p>
<pre class="crayon-plain-tag">EXPLAIN
SELECT *FROM tbl_ItemTransactions
WHERE TranID = 80

'Index Scan using idx_tranid on tbl_itemtransactions  (cost=0.42..8.44 rows=1 width=18)'
'  Index Cond: (tranid = 80)'</pre> </p>
<p><strong>Now, Use the early created function in the same query:</strong><br />
You can find &#8216;Seq Scan&#8217; because the function of the filter is creating a problem. Because VOLATILE is the default volatility classification.</p>
<pre class="crayon-plain-tag">EXPLAIN
SELECT *FROM tbl_ItemTransactions
WHERE TranID = fn_getvalues (50,80);

'Seq Scan on tbl_itemtransactions  (cost=0.00..183520.26 rows=1 width=18)'
'  Filter: (tranid = fn_getvalues(50, 80))'</pre> </p>
<p><strong>Now, Let&#8217;s create an IMMUTABLE function:</strong></p>
<pre class="crayon-plain-tag">CREATE OR REPLACE FUNCTION fn_getvalues(int, int)
RETURNS int
AS
$$
  BEGIN
       RETURN 
       	CASE WHEN $1 = $2 THEN $1 ELSE $2 END;
  END;
$$ LANGUAGE 'plpgsql' IMMUTABLE;</pre> </p>
<p><strong>Check the same query again:</strong><br />
You can find &#8216;Index Scan&#8217; which is expected and correct behaviour.<br />
EXPLAIN</p>
<pre class="crayon-plain-tag">SELECT *FROM tbl_ItemTransactions
WHERE TranID = fn_getvalues (50,80);

'Index Scan using idx_tranid on tbl_itemtransactions  (cost=0.42..8.44 rows=1 width=18)'
'  Index Cond: (tranid = 80)'</pre> </p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.dbrnd.com/2018/12/postgresql-optimize-the-function-by-defining-volatility-classification-immutable-volatile-stable/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>PostgreSQL: Script to find all Objects of a Particular User</title>
		<link>https://www.dbrnd.com/2018/09/postgresql-script-to-find-all-objects-of-a-particular-user/</link>
					<comments>https://www.dbrnd.com/2018/09/postgresql-script-to-find-all-objects-of-a-particular-user/#comments</comments>
		
		<dc:creator><![CDATA[Anvesh Patel]]></dc:creator>
		<pubDate>Mon, 03 Sep 2018 16:16:58 +0000</pubDate>
				<category><![CDATA[PostgreSQL]]></category>
		<category><![CDATA[PostgreSQL DBA Script]]></category>
		<category><![CDATA[Anvesh Patel]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[database research and development]]></category>
		<category><![CDATA[Database Role]]></category>
		<category><![CDATA[database user]]></category>
		<category><![CDATA[dbrnd]]></category>
		<category><![CDATA[pg_class]]></category>
		<category><![CDATA[pg_roles]]></category>
		<category><![CDATA[plpgsql]]></category>
		<category><![CDATA[Postgres]]></category>
		<category><![CDATA[Postgres Query]]></category>
		<category><![CDATA[postgresql]]></category>
		<category><![CDATA[PostgreSQL Administrator]]></category>
		<category><![CDATA[PostgreSQL Error]]></category>
		<category><![CDATA[PostgreSQL Monitoring]]></category>
		<category><![CDATA[PostgreSQL Performance Tuning]]></category>
		<category><![CDATA[PostgreSQL Programming]]></category>
		<category><![CDATA[PostgreSQL Tips and Tricks]]></category>
		<guid isPermaLink="false">https://www.dbrnd.com/?p=7708</guid>

					<description><![CDATA[In this post, I am sharing a script for getting the list of objects of a particular User (Owner of the Object) in PostgreSQL. Generally, PostgreSQL DBAs are using this kind of script for auditing purpose and object tracking purpose. Using the below script, you can get the list object for a particular user: I [&#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%2F2018%2F09%2Fpostgresql-script-to-find-all-objects-of-a-particular-user%2F&amp;linkname=PostgreSQL%3A%20Script%20to%20find%20all%20Objects%20of%20a%20Particular%20User" 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%2F09%2Fpostgresql-script-to-find-all-objects-of-a-particular-user%2F&amp;linkname=PostgreSQL%3A%20Script%20to%20find%20all%20Objects%20of%20a%20Particular%20User" 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%2F09%2Fpostgresql-script-to-find-all-objects-of-a-particular-user%2F&amp;linkname=PostgreSQL%3A%20Script%20to%20find%20all%20Objects%20of%20a%20Particular%20User" 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%2F09%2Fpostgresql-script-to-find-all-objects-of-a-particular-user%2F&amp;linkname=PostgreSQL%3A%20Script%20to%20find%20all%20Objects%20of%20a%20Particular%20User" 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%2F09%2Fpostgresql-script-to-find-all-objects-of-a-particular-user%2F&amp;linkname=PostgreSQL%3A%20Script%20to%20find%20all%20Objects%20of%20a%20Particular%20User" 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%2F09%2Fpostgresql-script-to-find-all-objects-of-a-particular-user%2F&amp;linkname=PostgreSQL%3A%20Script%20to%20find%20all%20Objects%20of%20a%20Particular%20User" 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%2F09%2Fpostgresql-script-to-find-all-objects-of-a-particular-user%2F&#038;title=PostgreSQL%3A%20Script%20to%20find%20all%20Objects%20of%20a%20Particular%20User" data-a2a-url="https://www.dbrnd.com/2018/09/postgresql-script-to-find-all-objects-of-a-particular-user/" data-a2a-title="PostgreSQL: Script to find all Objects of a Particular User"></a></p><p>In this post, I am sharing a script for getting the list of objects of a particular User (Owner of the Object) in PostgreSQL.<br />
Generally, PostgreSQL DBAs are using this kind of script for auditing purpose and object tracking purpose. </p>
<p>Using the below script, you can get the list object for a particular user:</p>
<p>I used a &#8216;postgres&#8217; default user in WHERE condition, which you can edit as per your user.</p>
<pre class="crayon-plain-tag">select 
    nsp.nspname as SchemaName
    ,cls.relname as ObjectName 
    ,rol.rolname as ObjectOwner
    ,case cls.relkind
        when 'r' then 'TABLE'
        when 'm' then 'MATERIALIZED_VIEW'
        when 'i' then 'INDEX'
        when 'S' then 'SEQUENCE'
        when 'v' then 'VIEW'
        when 'c' then 'TYPE'
        else cls.relkind::text
    end as ObjectType
from pg_class cls
join pg_roles rol 
	on rol.oid = cls.relowner
join pg_namespace nsp 
	on nsp.oid = cls.relnamespace
where nsp.nspname not in ('information_schema', 'pg_catalog')
    and nsp.nspname not like 'pg_toast%'
    and rol.rolname = 'postgres'  
order by nsp.nspname, cls.relname</pre> </p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.dbrnd.com/2018/09/postgresql-script-to-find-all-objects-of-a-particular-user/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
			</item>
	</channel>
</rss>
