How to limit the number of connections on the level of DB user in the Postgres Server?
ALTER USER my_db_user WITH CONNECTION LIMIT 2;
SELECT rolname, rolconnlimit
FROM pg_roles
WHERE rolconnlimit <> -1;
This query will return nothing if you don't have any custom roll limits set up.
How to limit the number of connections on the level of the
specific database in the Postgres Server?
postgres=> select datconnlimit from pg_database where datname='my_database';
datconnlimit
--------------
0
(1 row)
Reset to default value (i.e. no limit).
postgres=> alter database my_database connection limit -1;
ALTER DATABASE
postgres=> \q
dmitryr@dmitryr-mac my_postgres %
Top comments (0)