News for hackers. Stuff that matters.
Re:PostgreSQL and UUID as Primary Key by iterateoften on Saturday July 06, 2024 @06:07AM (#40889388)
If you have an index on the uuid anyways having a separate big serial field for PK doesn’t help that much.
Re:PostgreSQL and UUID as Primary Key by rezonant on Saturday July 06, 2024 @07:55AM (#40889864)
As mentioned elsewhere, it ensures the ability to perform resumable and consistent batching queries across the data set without missing records.

Ordering over an insertion timestamp is not enough if two records may have the same timestamp: You may miss a record (or visit a record twice) across multiple queries.

Re:PostgreSQL and UUID as Primary Key by disneycember on Saturday July 06, 2024 @09:21AM (#40890307)
This is solved sorting by timestamp first then by random PK UUID. Don't think a little simpler batch queries justify leaking time and quantity information or complexity of handling two types of IDs.
Re:PostgreSQL and UUID as Primary Key by j45 on Saturday July 06, 2024 @02:46PM (#40892307)
I agree with not baking more intelligence into a piece of data than needed, especially an index.
Re:PostgreSQL and UUID as Primary Key by rezonant on Saturday July 06, 2024 @04:50PM (#40893171)
You wouldn't expose the numeric IDs publically, and ideally you'd use your database's automatic ID selection to avoid any complexity.

The UUID sorting works in the common case, but if you happen to end your batch near the current time, you still run the risk of losing a few records if the insert frequency is sufficiently high. Admittedly this is only a problem when you are batching through all the way to current insertions.