一、最大连接数查看
postgresql数据库最大连接数是系统允许的最大连接数,当数据库并发用户超过该连接数后,会导致新连接无法建立或者连接超时。
最大连接数max_connections默认值为100。
当前总共正在使用的连接数
# select count(1) from pg_stat_activity;
显示系统允许的最大连接数,此数值包含为超级用户预留的连接数
# show max_connections;
显示系统保留的用户数superuser_reserved_connections
此参数为数据库为超级用户预留的连接数,默认值为3。当数据库的连接数达到(max_connections - superuser_reserved_connections)时,只有超级用户才能建立新的数据库连接,普通用户连接时将会返回错误信息“FATAL: sorry, too many clients already.”或者“FATAL: remaining connection slots are reserved for non-replication superuser connections”,登录数据库查询。
# sh