1, query database version

 select version();

2, query the running time of database

 select current_timestamp-pg_postmaster_start_time() as uptime;

3, query the data volume of the database

SELECT

datname ,

a.rolname ,

pg_encoding_to_char(encoding) ,

datcollate ,

datctype ,

pg_size_pretty(pg_database_size(datname))

FROM

pg_database d ,

pg_authid a

WHERE

d.datdba = a.oid

AND datname NOT IN ('template0' ,'template1' ,'postgres' )

ORDER BY

pg_database_size(datname) DESC;

4, query mobile game database connection number usage

SELECT

S.s etting "available" the number of connections, a.u sed_session "has been the use of the number of connections", s.setting::bigintwww.diuxie.com - a.u sed_session "remaining number of connections"

FROM

    pg_settings s,

    (

            SELECT

                    COUNT(*) AS used_session

            FROM

                    pg_stat_activity) a

WHERE

    s.name='max_connections';


5, query database parameter configuration

 select name,setting,unit  from pg_settings;

6, query the current database

 select current_database();