Right query to get the current number of connections in a PostgreSQL DB

Right query to get the current number of connections in a PostgreSQL DB

Asked on January 8, 2019 in PostgreSQL.
Add Comment


  • 2 Answer(s)

    Remember that it is not for a particular database.No of tcp connections will help you.

    netstat -a -n | find /c “127.0.0.1:13306”

    Answered on January 8, 2019.
    Add Comment

    This query is solve your issue:

    select * from
    (select count(*) used from pg_stat_activity) q1,
    (select setting::int res_for_super from pg_settings where name=$$superuser_reserved_connections$$) q2,
    (select setting::int max_conn from pg_settings where name=$$max_connections$$) q3;
    
    Answered on January 8, 2019.
    Add Comment


  • Your Answer

    By posting your answer, you agree to the privacy policy and terms of service.