8-byte integers are now the default for Postgres 8.4, so it allows microsecond values to be stored.
I don't care too much about real microsecond precision (probably depends on OS capabilities?!) - But does Postgres guarantee, that the timestamp values (inserted by current_timestamp
) are always different between any two transactions?
PostgreSQL stores the timestamptz in UTC value. When you insert a value into a timestamptz column, PostgreSQL converts the timestamptz value into a UTC value and stores the UTC value in the table.
PostgreSQL supports the full set of SQL date and time types, shown in Table 8.9.
#Example 1 In PostgreSQL, a column's current timestamp is used as the default value, and the current timestamp and time are used to deliver values with the time zone. The current statement's start time is the time of the most recent command received from you.
No.
I did a small test, inserting current_timestamp
from 5 parallell clients in a table, 3 of 3463 records got the same timestamp.
Yes, precision depends on the OS. Within a single transaction the timestamps are all the same when using CURRENT_TIMESTAMP, when using CLOCK_TIMESTAMP they might be different. Different transactions can have different CURRENT_TIMESTAMPS, depends on how fast you can insert/update.
If you need uniqueness, add a unique constraint.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With