postgres 连接数查看与设置操作

来源:脚本之家 时间:2021-05-19

PG中有一张表记录着当前有多少连接

表名:pg_stat_activity

查询当前连接数

1select count(1) from pg_stat_activity;

查询最大连接数

1show max_connections;

最大连接数也可以在pg配置文件中配置:

在postgresql.conf中设置:

1max_connections = 500

补充:Postgresql之连接数过多处理

如下:

//查看过期连接
select * from pg_stat_activity where state = 'idle'
 
//删除连接,括号里传pid
select pg_terminate_backend(25800);
 
//查看最大连接数
show max_connections;
 
//修改最大连接数,需要superuser权限
alter system set max_connections= 1000;

文章来源:脚本之家

来源地址:https://www.jb51.net/article/205089.htm

相关文章

A5创业网 版权所有

返回顶部