Postgres: database uptime
Formatted Uptime To display uptime in a more readable format (e.g., truncated to seconds):
SELECT date_trunc('second', current_timestamp - pg_postmaster_start_time()) AS uptime;
You can calculate the server uptime by querying the pg_postmaster_start_time() function, which returns the server's start time.
Basic Query To get the uptime directly:
SELECT current_timestamp - pg_postmaster_start_time() AS uptime;
Comments
Post a Comment