Re: timestamp precision

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: timestamp precision
Дата
Msg-id 9563.1095085732@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: timestamp precision  (Michael Glaesemann <grzm@myrealbox.com>)
Ответы Re: timestamp precision  (A Gilmore <agilmore@shaw.ca>)
Список 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 по дате отправления:

Предыдущее
От: Betsy Barker
Дата:
Сообщение: LockAcquire: lock table 1 is out of memory
Следующее
От: Tom Lane
Дата:
Сообщение: Re: LockAcquire: lock table 1 is out of memory