<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Vivek Kumar Singh</title>
    <description>The latest articles on DEV Community by Vivek Kumar Singh (@viveksyngh).</description>
    <link>https://dev.to/viveksyngh</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F199434%2Fc6a2aef6-cab6-4bca-8b58-02e7f11068d2.jpeg</url>
      <title>DEV Community: Vivek Kumar Singh</title>
      <link>https://dev.to/viveksyngh</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/viveksyngh"/>
    <language>en</language>
    <item>
      <title>Managing connections in PostgreSQL</title>
      <dc:creator>Vivek Kumar Singh</dc:creator>
      <pubDate>Tue, 12 May 2020 07:41:25 +0000</pubDate>
      <link>https://dev.to/viveksyngh/managing-connections-in-postgresql-3470</link>
      <guid>https://dev.to/viveksyngh/managing-connections-in-postgresql-3470</guid>
      <description>&lt;p&gt;Commands to manage maximum number of connections in a PostgresSQL&lt;/p&gt;

&lt;h3&gt;
  
  
  Get &lt;code&gt;max_connections&lt;/code&gt; value
&lt;/h3&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;show max_connections;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h3&gt;
  
  
  Updating &lt;code&gt;max_connections&lt;/code&gt; value
&lt;/h3&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;alter system set max_connections = 1000;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;and then restart the service&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo service postgresql restart
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h3&gt;
  
  
  Count number of used connections
&lt;/h3&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SELECT sum(numbackends) FROM pg_stat_database;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h3&gt;
  
  
  List all connections
&lt;/h3&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;select * from pg_stat_activity;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



</description>
      <category>database</category>
      <category>postgres</category>
    </item>
  </channel>
</rss>
