I want to limit the number of users per database in a multi tenant environment. But there are three levels of max connections and I should be grateful for any advice.
Level 1 Entire Server
By editing the config for Postgresql I can set the Max connection for the all databases on a server
postgresql.conf = max_connections = 100
Level 2 Per database
I can select and set the database connection limit per database:
SELECT datconnlimit FROM pg_database
Level 3 Per role
I can select and set the role connection limit per "user":
SELECT rolconnlimit FROM pg_roles
My questions are
If the max_connections in postgresql.conf is 100, will it be max connections of all databases regardless database and role settings? e.g. 100 databases can only have 1 connection each simultaneously?
Where is the best place to limit max connections. At the database level or at the role level?
Anything other to be considered?
TIA for any advice or clue!
max_connections
,datconnlimit
, androlconnlimit
are all the same, governed by the lowest one. – Rightfulsuperuser_reserved_connections
.datconnlimit
androlconnlimit
are not enforced for superusers. – Rightful