Same Millisecond, Different Story

A service assigns UUIDv7 primary keys and paginates a feed with ORDER BY id, assuming identifiers strictly increase with creation order. QA finds that two rows written within the same millisecond sometimes appear in the reverse of their creation order. Why?

A

The timestamp counts milliseconds from the moment each generating process started rather than from a shared epoch, so identifiers minted by two different processes cannot be compared at all

B

UUIDv7 only orders down to the millisecond, and the bits below the timestamp are random unless the generator adds a monotonic counter for identifiers sharing a millisecond

C

UUIDv7 stores its 48 bit timestamp in little-endian byte order, so comparing two identifiers byte by byte reverses the order in which they were created

D

The database compares UUID values as text rather than as 128 bit integers, so ordering below the first hyphen group follows character codes instead of time