Re: BUG #14838: clock_timestamp() returns same values for each row

From: Magnus Hagander <magnus(at)hagander(dot)net>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Jeff Janes <jeff(dot)janes(at)gmail(dot)com>, zam6ak(at)gmail(dot)com, Pg Bugs <pgsql-bugs(at)postgresql(dot)org>
Subject: Re: BUG #14838: clock_timestamp() returns same values for each row
Date: 2017-09-29 22:54:04
Message-ID: CABUevEyHu74AtDyB96t7r+LgbN2beBJhdxOhMVE2Ch9izkQ9GQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Fri, Sep 29, 2017 at 8:03 PM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:

> Jeff Janes <jeff(dot)janes(at)gmail(dot)com> writes:
> > On Fri, Sep 29, 2017 at 6:43 AM, <zam6ak(at)gmail(dot)com> wrote:
> >> We use clock_timestamp() function in our code and I have noticed that
> in PG
> >> 10 RC1 it returns same values across rows...
>
> > Probably not an issue of the different versions, but rather different
> > compilers (or maybe different hardware?).
>
> AFAICS, our code in this area (see src/port/gettimeofday.c) has not
> changed since 9.5. I'm suspicious of a platform change.
>
> > I get the same behavior on these two versions:
> > ...
> > and that behavior is that the timestamp jumps 500 usec at a time, despite
> > looking as if it might have usec granularity:
>
> What gettimeofday.c does is to use GetSystemTimePreciseAsFileTime()
> if it can get hold of that, otherwise fall back to
> GetSystemTimeAsFileTime(). I don't see anything very specific in
> Windows' documentation about the resolution to be expected from either
> one, but I wonder if the OP's 9.6 installation is using the former
> while for some reason his 10rc1 installation is using the latter.
>

The documentatino for GetSystemTimePreciseAsFileTime() specifically says "the
current system date and time with the highest possible level of precision
(<1us)". Which is not super specific, but certainly a lot lower than the
500us observed.

GetSystemTime() is AFAIK at millisecond level, I recall reading about 10ms.

--
Magnus Hagander
Me: https://www.hagander.net/ <http://www.hagander.net/>
Work: https://www.redpill-linpro.com/ <http://www.redpill-linpro.com/>

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Lucas O 2017-09-30 17:49:41 bug report
Previous Message zambak zambak 2017-09-29 22:41:43 Re: BUG #14838: clock_timestamp() returns same values for each row