I have written a java code for bulk insertion. I'm using the copy command for importing and creating different connection objects for different tables, but while executing, the program it is throwing the following errors:
FATAL: connection limit exceeded for non-superusers
Firstly, run the following command in a Postgres console: alter system set max_connections = 30; (or whatever number of connections you'd like). Next, you need to restart your Postgres server.
This means you've had enough concurrent connections to surpass your limit or hit a warning.
PostgreSQL Connection Limits 15 connections are reserved for the superuser to maintain the state and integrity of your database, and 100 connections are available for you and your applications. If the number of connections to the database exceeds the 100-connection limit, new connections fail and return an error.
You have exceeded the connection limit of PostgreSQL server. There are some reserved connection for Super user.
To increase the connection limit you have to change the postgresql.conf (default 100) it is located on your PostgreSQL data directory.
cat postgresql.conf | grep max_connection max_connections = 100
# (change requires restart)
# Note: Increasing max_connections costs ~400 bytes of shared memory per
# max_locks_per_transaction * (max_connections + max_prepared_transactions)
Increase the limit and restart the PostgreSQL instance.
Warning: increasing the connection limit will affect the memory.
try optimizing connection using connection pooling either in application or db layer. on PostgreSQL you can use Pgpool2.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With