查询数据库创建及开启时间
postgres=# select * from pg_control_system();
pg_control_version | catalog_version_no | system_identifier | pg_control_last_modified
--------------------+--------------------+---------------------+--------------------------
1300 | 202107181 | 7138706916767955981 | 2022-09-20 16:35:21+08
(1 row)
Time: 0.408 ms
########查询数据库创建时间
postgres=# select to_timestamp(((system_identifier>>32) & (2^32 -1)::bigint)) from pg_control_system();;
to_timestamp
------------------------
2022-09-02 17:08:46+08
(1 row)
Time: 0.206 ms
Time: 0.013 ms
##### 查询数据库开机时间
postgres=# select * from pg_postmaster_start_time();
pg_postmaster_start_time
-------------------------------
2022-09-20 10:05:20.796858+08
(1 row)
Time: 0.217 ms