Re: timestamp precision - Mailing list pgsql-novice

From Tom Lane
Subject Re: timestamp precision
Date
Msg-id 9563.1095085732@sss.pgh.pa.us
Whole thread Raw
In response to Re: timestamp precision  (Michael Glaesemann <grzm@myrealbox.com>)
Responses Re: timestamp precision
List pgsql-novice
Michael Glaesemann <grzm@myrealbox.com> writes:
> On Sep 13, 2004, at 4:19 PM, A Gilmore wrote:
>> Im using the default precision for my timestamps, 6.  Is it safe to
>> declare this column unique?

> If you are assuming it's unique because of the high precision, well,
> you might get lucky, and you might not. (Some might even argue that
> it's for all intents and purposes unique).

I think what he's wondering is whether every two transactions will get
distinguishable values of now(), so that putting a UNIQUE constraint on
timestamps inserted by distinct transactions could never fail.

I think this is an unsafe assumption, because:

1.  The amount of precision that is actually in the now() value is
unspecified, and varies depending on the hardware and OS.  On older
machines it's quite possible that now() only advances once per clock
tick interrupt (60 or 100 times per second).

2.  Even if the now() quantum is less than the minimum time to complete
a transaction, what if two clients launch transactions concurrently?

            regards, tom lane

pgsql-novice by date:

Previous
From: Betsy Barker
Date:
Subject: LockAcquire: lock table 1 is out of memory
Next
From: Tom Lane
Date:
Subject: Re: LockAcquire: lock table 1 is out of memory