Return the timestamp at which the server process started.
PG_POSTMASTER_START_TIME()
## Overview Returns the TIMESTAMP WITH TIME ZONE at which the backend process was started. Use this function to compute server uptime, correlate incidents with deploy times, or include in diagnostic snapshots. ## Session context - The value reflects the whole server, not the session. - Fixed for the lifetime of the process. - Takes no arguments. - Never returns NULL. ## Behavior - Returns a TIMESTAMP WITH TIME ZONE. - Deterministic for a given process. - Side effect free. ## Compatibility - PG-compat alias for `pg_postmaster_start_time` function.
-- Read the server start time
SELECT PG_POSTMASTER_START_TIME();
-- Calculate server uptime
SELECT CURRENT_TIMESTAMP - PG_POSTMASTER_START_TIME() AS uptime;
-- Include in a diagnostics snapshot
SELECT PG_POSTMASTER_START_TIME() AS started, VERSION() AS engine;
-- Detect that a config reload has occurred after startup
SELECT PG_CONF_LOAD_TIME() > PG_POSTMASTER_START_TIME() AS was_reloaded;