File tree Expand file tree Collapse file tree 1 file changed +22
-2
lines changed Expand file tree Collapse file tree 1 file changed +22
-2
lines changed Original file line number Diff line number Diff line change 7
7
rolcanlogin AS can_login,
8
8
rolreplication AS is_replication_role,
9
9
rolbypassrls AS can_bypass_rls,
10
- rolconnlimit AS connection_limit,
10
+ active_connections,
11
+ CASE WHEN rolconnlimit = - 1 THEN max_db_connections :: int4
12
+ ELSE rolconnlimit
13
+ END AS connection_limit,
11
14
rolpassword AS password,
12
15
rolvaliduntil AS valid_until,
13
16
rolconfig AS config,
14
- oid
17
+ oid AS id
15
18
FROM
16
19
pg_catalog .pg_roles
20
+ INNER JOIN LATERAL (
21
+ SELECT
22
+ count (* ) AS active_connections
23
+ FROM
24
+ pg_stat_activity
25
+ WHERE
26
+ state = ' active'
27
+ AND pg_roles .rolname = pg_stat_activity .usename
28
+ ) AS active_connections ON 1 = 1
29
+ INNER JOIN LATERAL (
30
+ SELECT
31
+ setting AS max_db_connections
32
+ FROM
33
+ pg_settings
34
+ WHERE
35
+ name = ' max_connections'
36
+ ) AS max_db_connections ON 1 = 1
You can’t perform that action at this time.
0 commit comments