You may wonder, How long is it since the server started?
As mentioned in the previous recipe, we will find this out by asking the database server.
You may wonder, How long is it since the server started?
As mentioned in the previous recipe, we will find this out by asking the database server.
Issue the following SQL from any interface:
postgres=# SELECT date_trunc('second',
current_timestamp - pg_postmaster_start_time()) as uptime;
You should get an output as follows:
uptime
--------------------------------------
2 days 02:48:04
Postgres stores the server start time, so we can access it directly, as follows:
postgres=# SELECT pg_postmaster_start_time...