我们正在使用PostgreSQL。是否有任何命令可以知道,最大连接数是多少?目前使用多少?可以建立多少个额外的连接?
是否有任何命令或SQL查询要运行并检查所有这些?
smth like应该可以工作:
t=# select current_setting('max_connections')::int - count(1) from pg_stat_activity;
?column?
----------
93
(1 row)
其中允许的最大current_setting('max_connections')
,并且pg_stat_activity
知道您有多少连接以及您有多少类型(列state
(
这应该可以解决问题:
SELECT current_setting('max_connections')::bigint,
current_setting('superuser_reserved_connections')::bigint,
count(*) AS current_connections
FROM pg_stat_activity
WHERE datid IS NOT NULL;
可用连接数是第一个条目减去其他两个条目。
你可以检查max_connections:
postgres=# show max_connections;
输出:
max_connections
-----------------
30
(1 row)