1、进入数据库
#sudo su - postgres #psql
2、查询当前总共正在使用的连接数:
select count(1) from pg_stat_activity;
3、按照用户分组查看
select usename, count(*) from pg_stat_activity group by usename order by count(*) desc;
4、查询当前所有连接的状态
select datname,pid,application_name,state from pg_stat_activity;
5、显示系统允许的最大连接数
show max_connections;
6、修改最大连接数
alter system set max_connections= 5000
7、pg库连接数释放
SELECT pg_terminate_backend(pid) FROM pg_stat_activity WHERE state='idle';
标签:count,stat,postgres,连接数,指令,pg,activity,select From: https://www.cnblogs.com/meng-ma-blogs/p/17812445.html