How to find out the connection limit per user on Postgresql?

miller_121 picture miller_121 · Jan 6, 2011 · Viewed 47.7k times · Source

I need to find out if a connection limit has been set on a Postgresql database on a per user basis.

I know you can set such a limit using:

ALTER USER johndoe WITH CONNECTION LIMIT 2;

Can you check this in the pg_users table?

Answer

DrColossos picture DrColossos · Jan 6, 2011

Whilst connected to the database you want to get this information

SELECT rolname, rolconnlimit
FROM pg_roles
WHERE rolconnlimit <> -1;

More details are available at http://www.postgresql.org/docs/current/static/view-pg-roles.html