top | item 40890625

(no title)

x3al | 1 year ago

Strictly monotonic fields are quite expensive and the bigserial PK alone won't give you that.

discuss

order

kroolik|1 year ago

PG bigserial is already strictly monotonic

blackenedgem|1 year ago

No they're not, even with a `cache` value of 1. Sequence values are issued at insert rather than commit. A transaction that commits later (which makes all updates visible) can have an earlier value than a previous transaction.

This is problematic if you try to depend on the ordering. Nothing is stopping some batch process that started an hour ago from committing a value 100k lower than where you thought the sequence was at. That's an extreme example but the consideration is the same when dealing with millisecond timeframes.