skip to Main Content

As an example, if I have 3 users in Postgres, lets call them user_a, user_b, user_c… How can I ensure that they cannot hold more than two open connections at the same time? I may also have a user called user_z, and I would be happy to have them hold over 100+ connections. So limiting the overall number of connections in the db is not an option.

I looked into connection limit inheritance for roles but I cannot seem to find a clear answer on if this is the right path to go down.

2

Answers


  1. You can create roles, give each role its own connection limit, and then assign the users appropriately.

    Login or Signup to reply.
  2. The best I can think of is an event trigger that triggers on login, checks the currently active sessions and throws a FATAL error if the quota is exceeded. That is not an elegant solution, but then the requirement is quite unusual.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search