Re: uptime() for postmaster - Mailing list pgsql-hackers

From Greg Stark
Subject Re: uptime() for postmaster
Date
Msg-id 87llb97kte.fsf@stark.xeocode.com
Whole thread Raw
In response to Re: uptime() for postmaster  (Gaetano Mendola <mendola@bigfoot.com>)
List pgsql-hackers
Gaetano Mendola <mendola@bigfoot.com> writes:

> Well, the unix guys have the abit to have the uptime as an interval, I'm
> inclined to have boths:  pg_uptime ( interval ) and pg_starttime ( timestamptz )

Well for the OS these are not redundant values. The clock could have been
adjusted at any time. So you can't just calculate uptime by subtracting the
current time from the start time.

I suppose this argument is true for Postgres as well. But I'm not sure
Postgres can really make the distinction as easily as the kernel. To return
the actual uptime without being deceived by clock changes it would need to
store not the wall clock time on startup, but the system uptime. And then
calculate the difference in the current system uptime. I'm not sure if there
is a portable interface to get a system uptime.

-- 
greg



pgsql-hackers by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: [PATCHES] Bgwriter behavior
Next
From: Simon Riggs
Date:
Subject: Re: [PATCHES] Bgwriter behavior