12938 | postgres | 16576 | postgres | active | ::1 | select datid,datname,pid,usename,state,client_addr,query from pg_stat_activity;
16394 | lib1 | 13592 | postgres | idle | 127。0。0。1 | SELECT id,name,age,email FROM guser WHERE id=$1
16394 | lib1 | 11140 | postgres | idle | 127。0。0。1 | SET application_name = 'PostgreSQL JDBC Driver'
16394 | lib1 | 14976 | postgres | idle | 127。0。0。1 | SET application_name = 'PostgreSQL JDBC Driver'
16394 | lib1 | 9508 | postgres | idle | 127。0。0。1 | SET application_name = 'PostgreSQL JDBC Driver'
16394 | lib1 | 6728 | postgres | idle | 127。0。0。1 | SET application_name = 'PostgreSQL JDBC Driver'
16394 | lib1 | 12988 | postgres | idle | 127。0。0。1 | SET application_name = 'PostgreSQL JDBC Driver'
16394 | lib1 | 15288 | postgres | idle | 127。0。0。1 | SET application_name = 'PostgreSQL JDBC Driver'
16394 | lib1 | 12872 | postgres | idle | 127。0。0。1 | SET application_name = 'PostgreSQL JDBC Driver'
16394 | lib1 | 13108 | postgres | idle | 127。0。0。1 | SET application_name = 'PostgreSQL JDBC Driver'
16394 | lib1 | 19376 | postgres | idle | 127。0。0。1 | SET application_name = 'PostgreSQL JDBC Driver'
| | 14144 | | | |
| | 9304 | | | |
| | 992 | | | |
(16 行记录)
注意,其中有10个idle的连接,这个来自本机的一个Spring Boot程序。默认的数据库拦截池使用 HikariCP,十个连接。
更换为Druid数据库后:配置了更少的初始数据库连接(当然,HikariCP也可以配置),,这次只有8个了
lib2=# select datid,datname,pid,usename,state,client_addr,query from pg_stat_activity;
datid | datname | pid | usename | state | client_addr | query
-------+---------+-------+----------+--------+-------------+---------------------------------------------------------------------------------
| | 18904 | | | |
| | 18556 | postgres | | |
16402 | lib2 | 15936 | postgres | active | ::1 | select datid,datname,pid,usename,state,client_addr,query from pg_stat_activity;
16394 | lib1 | 2940 | postgres | idle | 127。0。0。1 | SELECT id,name,age,email FROM guser WHERE id=$1
postgresql命令大全postgresql常用命令(7):http://www.youerw.com/fanwen/lunwen_99316.html