<?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>super user &#8211; Database Research &amp; Development</title>
	<atom:link href="https://www.dbrnd.com/tag/super-user/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, 21 Jan 2019 07:21:02 +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: 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: FATAL Error &#8211; remaining connection slots are reserved for non-replication superuser connections</title>
		<link>https://www.dbrnd.com/2017/07/postgresql-fatal-error-remaining-connection-slots-are-reserved-for-non-replication-superuser-connections/</link>
		
		<dc:creator><![CDATA[Anvesh Patel]]></dc:creator>
		<pubDate>Fri, 07 Jul 2017 16:16:13 +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[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>
		<guid isPermaLink="false">https://www.dbrnd.com/?p=5581</guid>

					<description><![CDATA[Few weeks ago, We got an error in one of our client PostgreSQL Server. Below is an error: psql.bin: FATAL: remaining connection slots are reserved for non-replication superuser connections The solution of above error is also very straightforward and short. You are getting this error because your server exceeded the limit of max_connections parameter.max_connection. The [&#8230;]]]></description>
										<content:encoded><![CDATA[<p><a class="a2a_button_facebook" href="https://www.addtoany.com/add_to/facebook?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2017%2F07%2Fpostgresql-fatal-error-remaining-connection-slots-are-reserved-for-non-replication-superuser-connections%2F&amp;linkname=PostgreSQL%3A%20FATAL%20Error%20%E2%80%93%20remaining%20connection%20slots%20are%20reserved%20for%20non-replication%20superuser%20connections" title="Facebook" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_twitter" href="https://www.addtoany.com/add_to/twitter?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2017%2F07%2Fpostgresql-fatal-error-remaining-connection-slots-are-reserved-for-non-replication-superuser-connections%2F&amp;linkname=PostgreSQL%3A%20FATAL%20Error%20%E2%80%93%20remaining%20connection%20slots%20are%20reserved%20for%20non-replication%20superuser%20connections" title="Twitter" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_linkedin" href="https://www.addtoany.com/add_to/linkedin?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2017%2F07%2Fpostgresql-fatal-error-remaining-connection-slots-are-reserved-for-non-replication-superuser-connections%2F&amp;linkname=PostgreSQL%3A%20FATAL%20Error%20%E2%80%93%20remaining%20connection%20slots%20are%20reserved%20for%20non-replication%20superuser%20connections" title="LinkedIn" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_pinterest" href="https://www.addtoany.com/add_to/pinterest?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2017%2F07%2Fpostgresql-fatal-error-remaining-connection-slots-are-reserved-for-non-replication-superuser-connections%2F&amp;linkname=PostgreSQL%3A%20FATAL%20Error%20%E2%80%93%20remaining%20connection%20slots%20are%20reserved%20for%20non-replication%20superuser%20connections" title="Pinterest" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_reddit" href="https://www.addtoany.com/add_to/reddit?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2017%2F07%2Fpostgresql-fatal-error-remaining-connection-slots-are-reserved-for-non-replication-superuser-connections%2F&amp;linkname=PostgreSQL%3A%20FATAL%20Error%20%E2%80%93%20remaining%20connection%20slots%20are%20reserved%20for%20non-replication%20superuser%20connections" title="Reddit" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_pocket" href="https://www.addtoany.com/add_to/pocket?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2017%2F07%2Fpostgresql-fatal-error-remaining-connection-slots-are-reserved-for-non-replication-superuser-connections%2F&amp;linkname=PostgreSQL%3A%20FATAL%20Error%20%E2%80%93%20remaining%20connection%20slots%20are%20reserved%20for%20non-replication%20superuser%20connections" title="Pocket" rel="nofollow noopener" target="_blank"></a><a class="a2a_dd addtoany_share_save addtoany_share" href="https://www.addtoany.com/share#url=https%3A%2F%2Fwww.dbrnd.com%2F2017%2F07%2Fpostgresql-fatal-error-remaining-connection-slots-are-reserved-for-non-replication-superuser-connections%2F&#038;title=PostgreSQL%3A%20FATAL%20Error%20%E2%80%93%20remaining%20connection%20slots%20are%20reserved%20for%20non-replication%20superuser%20connections" data-a2a-url="https://www.dbrnd.com/2017/07/postgresql-fatal-error-remaining-connection-slots-are-reserved-for-non-replication-superuser-connections/" data-a2a-title="PostgreSQL: FATAL Error – remaining connection slots are reserved for non-replication superuser connections"></a></p><p>Few weeks ago, We got an error in one of our client PostgreSQL Server. Below is an error:<br />
psql.bin: FATAL: remaining connection slots are reserved for non-replication superuser connections</p>
<p>The solution of above error is also very straightforward and short. You are getting this error because your server exceeded the limit of max_connections parameter.max_connection.</p>
<p><strong>The solution is:</strong></p>
<p><code>Increase the value of [max_connections] parameter:</li>
<p>Decrease the value of [superuser_reserved_connections] parameter:</code></p>
<p>You can find above both parameters in postgresql.conf file.<br />
Note: After changing parameters, you must restart the PostgreSQL cluster.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>PostgreSQL: Non Superuser can kill their own running queries</title>
		<link>https://www.dbrnd.com/2017/05/postgresql-non-superuser-can-kill-their-own-running-queries/</link>
		
		<dc:creator><![CDATA[Anvesh Patel]]></dc:creator>
		<pubDate>Tue, 30 May 2017 16:16:29 +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[Kill connections]]></category>
		<category><![CDATA[Kill idle session]]></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>
		<guid isPermaLink="false">https://www.dbrnd.com/?p=5348</guid>

					<description><![CDATA[In this post, I am sharing a UDF and using this non-super user can kill their queries. As a PostgreSQL DBA, You may find long running queries or IDLE queries of the user. Many times users also disturb to DBA for killing their queries. In my organisation, we created one function and assigned 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%2F2017%2F05%2Fpostgresql-non-superuser-can-kill-their-own-running-queries%2F&amp;linkname=PostgreSQL%3A%20Non%20Superuser%20can%20kill%20their%20own%20running%20queries" title="Facebook" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_twitter" href="https://www.addtoany.com/add_to/twitter?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2017%2F05%2Fpostgresql-non-superuser-can-kill-their-own-running-queries%2F&amp;linkname=PostgreSQL%3A%20Non%20Superuser%20can%20kill%20their%20own%20running%20queries" title="Twitter" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_linkedin" href="https://www.addtoany.com/add_to/linkedin?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2017%2F05%2Fpostgresql-non-superuser-can-kill-their-own-running-queries%2F&amp;linkname=PostgreSQL%3A%20Non%20Superuser%20can%20kill%20their%20own%20running%20queries" title="LinkedIn" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_pinterest" href="https://www.addtoany.com/add_to/pinterest?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2017%2F05%2Fpostgresql-non-superuser-can-kill-their-own-running-queries%2F&amp;linkname=PostgreSQL%3A%20Non%20Superuser%20can%20kill%20their%20own%20running%20queries" title="Pinterest" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_reddit" href="https://www.addtoany.com/add_to/reddit?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2017%2F05%2Fpostgresql-non-superuser-can-kill-their-own-running-queries%2F&amp;linkname=PostgreSQL%3A%20Non%20Superuser%20can%20kill%20their%20own%20running%20queries" title="Reddit" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_pocket" href="https://www.addtoany.com/add_to/pocket?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2017%2F05%2Fpostgresql-non-superuser-can-kill-their-own-running-queries%2F&amp;linkname=PostgreSQL%3A%20Non%20Superuser%20can%20kill%20their%20own%20running%20queries" title="Pocket" rel="nofollow noopener" target="_blank"></a><a class="a2a_dd addtoany_share_save addtoany_share" href="https://www.addtoany.com/share#url=https%3A%2F%2Fwww.dbrnd.com%2F2017%2F05%2Fpostgresql-non-superuser-can-kill-their-own-running-queries%2F&#038;title=PostgreSQL%3A%20Non%20Superuser%20can%20kill%20their%20own%20running%20queries" data-a2a-url="https://www.dbrnd.com/2017/05/postgresql-non-superuser-can-kill-their-own-running-queries/" data-a2a-title="PostgreSQL: Non Superuser can kill their own running queries"></a></p><p>In this post, I am sharing a UDF and using this non-super user can kill their queries.</p>
<p>As a PostgreSQL DBA, You may find long running queries or IDLE queries of the user. Many times users also disturb to DBA for killing their queries.</p>
<p>In my organisation, we created one function and assigned to all users so that they can kill their queries without disturbing to DBA team. </p>
<p>This function created such a way that, a user can kill their own queries only. They can find process_id of other users, but they can&#8217;t kill other queries.</p>
<p>Below is a full demonstration of this:</p>
<p><strong>Create a schema:</strong>﻿</p><pre class="crayon-plain-tag">CREATE SCHEMA query_admin;</pre><p> </p>
<p><strong>Create a function to kill user query:</strong></p><pre class="crayon-plain-tag">CREATE OR REPLACE FUNCTION query_admin.kill_process(userpid integer)
RETURNS boolean AS $body$
DECLARE
    qry boolean;
BEGIN
    qry := (SELECT pg_catalog.pg_cancel_backend(pid) 
            FROM pg_stat_activity 
            WHERE usename=(select session_user) 
            AND pid=userpid);
    RETURN qry;
END;
$body$
LANGUAGE plpgsql
SECURITY DEFINER
VOLATILE
RETURNS NULL ON NULL INPUT;</pre><p> </p>
<p><strong>Grant permission to Public so that all user can access this:</strong></p>
<pre class="crayon-plain-tag">GRANT USAGE ON SCHEMA query_admin TO public;
GRANT EXECUTE ON FUNCTION query_admin.kill_process(pid integer) TO public;</pre> </p>
<p><strong>User can check their running process_id queries using below query:</strong></p>
<pre class="crayon-plain-tag">SELECT * FROM pg_stat_activity 
WHERE usename = 'user_name';</pre> </p>
<p><strong>Sample execution of kill_process():</strong></p>
<pre class="crayon-plain-tag">SELECT *FROM query_admin.kill_process(process_id);
SELECT *FROM query_admin.kill_process(14526);</pre> </p>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
