postgre通過sql釋放空閑連接
– 查詢當前連接
select * from pg_stat_activity;
–查詢最大連接數
show max_connections;
– 釋放空閑連接
SELECT pg_terminate_backend(pid) FROM pg_stat_activity WHERE state=‘idle’;
遇到的問題
Postgres 致命錯誤: 對不起, 已經有太多的客戶 (pgjdbc: autodetected server-encoding to be GB2312, if the message is
出現這個錯誤,需要修改配置。找到postgresql.conf 修改連接數
max_connections = 2500 # (change requires restart)