measure time intervals

Started by Vincent Dautremontabout 14 years ago7 messagesgeneral
Jump to latest
#1Vincent Dautremont
vincent@searidgetech.com

Hi,
I'm wondering ig it is possible to measure elapsed time between 2
particular queries in PostgreSQL.

what I need is the equivalent of @@TIMETICKS in Transac-SQL
or CLOCK_MONOTONIC in Unix
or GetTickCount in Windows

These are not affected by system time changes, so time interval can be
calculated even if the system time is changed by NTP or the user.
That's why I can't use any function based on system time.

#2John R Pierce
pierce@hogranch.com
In reply to: Vincent Dautremont (#1)
Re: measure time intervals

On 04/05/12 7:00 AM, Vincent Dautremont wrote:

These are not affected by system time changes, so time interval can be
calculated even if the system time is changed by NTP or the user.
That's why I can't use any function based on system time.

properly configured Unix NTP doesn't step-change the clock, it very
gently slows it down or speeds it up until it is accurate and maintains
stability. and only root can change the clock on a Unix system, so this
really shouldn't be a concern.

--
john r pierce N 37, W 122
santa cruz ca mid-left coast

#3Vincent Dautremont
vincent@searidgetech.com
In reply to: John R Pierce (#2)
Re: measure time intervals

Thank you but my problem is precisely because I'm using Postrgresql on a
windows computer and I cannot change that :-/

Vincent.

On Fri, Apr 6, 2012 at 1:40 PM, John R Pierce <pierce@hogranch.com> wrote:

Show quoted text

On 04/05/12 7:00 AM, Vincent Dautremont wrote:

These are not affected by system time changes, so time interval can be
calculated even if the system time is changed by NTP or the user.
That's why I can't use any function based on system time.

properly configured Unix NTP doesn't step-change the clock, it very gently
slows it down or speeds it up until it is accurate and maintains stability.
and only root can change the clock on a Unix system, so this really
shouldn't be a concern.

--
john r pierce N 37, W 122
santa cruz ca mid-left coast

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/**mailpref/pgsql-general&lt;http://www.postgresql.org/mailpref/pgsql-general&gt;

#4Merlin Moncure
mmoncure@gmail.com
In reply to: Vincent Dautremont (#1)
Re: measure time intervals

On Thu, Apr 5, 2012 at 9:00 AM, Vincent Dautremont
<vincent@searidgetech.com> wrote:

Hi,
I'm wondering ig it is possible to measure elapsed time between 2 particular
queries in PostgreSQL.

what I need is the equivalent of @@TIMETICKS in Transac-SQL
or CLOCK_MONOTONIC  in Unix
or GetTickCount in Windows

These are not affected by system time changes, so time interval can be
calculated even if the system time is changed by NTP or the user.
That's why I can't use any function based on system time.

one way that will work is to write a C module for postgres that wraps
the system call. that's a heavy dependency for such a small thing
though. also FYI GetTickCount wraps around approximately every three
and a half weeks.

merlin

In reply to: Vincent Dautremont (#3)
Re: measure time intervals

On 10/04/2012 14:39, Vincent Dautremont wrote:

Thank you but my problem is precisely because I'm using Postrgresql on a
windows computer and I cannot change that :-/

Windows can adjust the time using NTP also, though I don't know how
abruptly or otherwise it does it. Under your date & time settings there
should be an "Internet time" tab.

There are also some Windows NTP clients which might be worth looking at.

Ray.

--
Raymond O'Donnell :: Galway :: Ireland
rod@iol.ie

#6Vincent Dautremont
vincent@searidgetech.com
In reply to: Raymond O'Donnell (#5)
Re: measure time intervals

Thank you.
I was searching if there was such feature included in postgresql.
I'll find another way around to achieve what I want with this.

As I have to use windows NTP colient and not a 3rd party client I'll go
check windows NTP client configuration, see if I can make it act as the
Unix one does.

Vincent.

On Tue, Apr 10, 2012 at 9:48 AM, Raymond O'Donnell <rod@iol.ie> wrote:

Show quoted text

On 10/04/2012 14:39, Vincent Dautremont wrote:

Thank you but my problem is precisely because I'm using Postrgresql on a
windows computer and I cannot change that :-/

Windows can adjust the time using NTP also, though I don't know how
abruptly or otherwise it does it. Under your date & time settings there
should be an "Internet time" tab.

There are also some Windows NTP clients which might be worth looking at.

Ray.

--
Raymond O'Donnell :: Galway :: Ireland
rod@iol.ie

#7John R Pierce
pierce@hogranch.com
In reply to: Raymond O'Donnell (#5)
Re: measure time intervals

On 04/10/12 6:48 AM, Raymond O'Donnell wrote:

Windows can adjust the time using NTP also, though I don't know how
abruptly or otherwise it does it. Under your date & time settings
there should be an "Internet time" tab.

the built in Windows Internet Time does a time step every 24 hours(or
something) to correct it, or at least it did this last time I looked
into it.

--
john r pierce N 37, W 122
santa cruz ca mid-left coast