pg postgresql空闲连接查看

今天在做的一个项目,由于数据量很大,直接连接npgsql,没有用框架,然后发现数据库连接超额奔溃了,用语句查询了一下:

select * from pg_stat_activity;----查询正在运行的连接

select max_conn-now_conn as resi_conn from (select setting::int8 as max_conn,(select count(*) from pg_stat_activity) as now_conn from pg_settings where name = 'max_connections') t----剩余数量

show max_connections ---允许最大链接数

alter system set idle_in_transaction_session_timeout=30000----设置释放空闲事务退出时间

posted @ 2021-08-04 10:03  Cetus-Y  阅读(751)  评论(0编辑  收藏  举报