andatki

Joined 3 years ago

Karma
40
Submissions
57
Member since
Aug 14
andyatkinson.com
View on Hacker News

Recent submissions

Comment · 1 month ago
Bryce Shivers and Lisa Eversman would definitely have this in their boutique. Put a Bird on It!
Comment · 2 months ago
Author here. Happy to discuss any points in the post and appreciate feedback, thanks.
Comment · 4 months ago
Happy to discuss any details from the post. Thanks for taking a look.
Comment · 9 months ago
Comment · 10 months ago
If merging or moving data between environments is a regular occurrence, I agree it would be best to have non-colliding primary keys. I have done an environment move (new DB in different AWS region) with integers and sequences for maybe a 100 table DB and it’s do-able but a high cost task. At that company we also had the demo/customer preview environment concept where we needed to keep the data but move it.
Comment · 10 months ago
Great!
Comment · 10 months ago
Good addition!
Comment · 10 months ago
This was written based on working on several Postgres databases at different companies of “medium” size as a consultant, that had excessive IO and latency and used UUID v4 PKs/FKs. They’re definitely out there. We could transform the schema for some key tables as a demonstration with big int equivalents and show the IO latency reduction. With that said, the real world PK data type migration is costly but becomes a business decision of whether to do or not.
Comment · 10 months ago
Appreciate it!
Comment · 10 months ago
Note that if you’re using UUID v4 now, switching to v7 does not require a schema migration. You’d get the benefits when working with new records, for example reduced insert latency. The uuid data type supports both.
Comment · 10 months ago
Hi there. Thanks for the feedback. I updated that section to hopefully convey the intent more. The type of ordering we care about for this topic is really B-Tree index traversal when inserting new entries and finding existing entries (single and multiple values i.e. an IN clause, updates, deletes etc). There's a compelling example I re-created from Cybertec showing the pages needed and accessed for equivalent user-facing results, comparing storing PKs as big integers vs. UUID v4s, and how many more pages were needed for v4 UUIDs. I found that to be helpful to support my real world experience as a consultant on various "medium sized" Postgres databases (e.g. single to 10s of millions of records) where clients were experiencing excessive latency for queries, and the UUID v4 PK/FKs selection made for reasons earlier was one of the main culprits. The indexes wouldn’t fit into memory resulting in a lot of sequential scans. I’d confirm this by showing an alternative schema design and set of queries where everything was the same except integer PKs/FKs were used. Smaller indexes (fit in memory), reliable index scans, less latency, faster execution time.
Comment · 10 months ago
Good point that the post should be made clear it’s referring only to my experience with Postgres.

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton