PostgreSQL how to set max connections, max_connections
Hello colleagues.
In today's article, I will tell you how to change the max_connections parameter in Postgresql. This setting is used to limit the connection to the database. max_connections is static and that's why you can't just change it in the console, you need to explicitly set it in the configuration file.
Article content:
- The current values of max_connections.
- Change max_connections in postgresql.conf.
- We restart the database.
- Examination.
1. The current values of max_connections.
Before changing max_connections, let's see how many maximum connections are currently set. To do this, use the command in the console:
psql> SHOW max_connections;
As you can see, 400 connections are now established.
2. Change max_connections in postgresql.conf.
To change the max_connections parameter, you need to change it in the postgresql.conf configuration file. Find it and change the values.
$. sudo vim $PG_HOME/postgresql.conf
Change the values from 400 to 500, then save and close the file.
3. I will restart the database.
$. pg_ctl restart
4. Examination.
After we changed the max_connections values from 400 to 500 and restarted the database, we can check the result. We repeat the first step:
psql> SHOW max_connections;
As you can see, everything worked out, the max_connections values were successfully applied.
Thank you all, I hope my article was of some help to you.