1. Query the database version

select version(); 2. Query the running time of the database

select current_timestamp-pg_postmaster_start_time() as uptime; 3. Query the amount of data in 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 the usage of mobile game database connection number if there is more intuitive understanding relative to electron, you can also refer to its format as follows:

www.diuxie.com

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"Copy the code

FROM

pg_settings s,

(

        SELECT

                COUNT(*) AS used_session

        FROM

                pg_stat_activity) a
Copy the code

WHERE

s.name='max_connections';
Copy the code

5. Query database parameter Settings

select name,setting,unit from pg_settings; 6. Query the current database

select current_database();