perf: Use UUIDv7 for Primary Key #2336
Reference in New Issue
Block a user
Delete Branch "use-uuid-v7"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
UUIDv7 has better index locality, which makes it more performant for large tables compared to UUIDv4. There is a nice article explaining the technical parts.
This PR introduces
gen_uuid_v7function in PG and updates all PK defaults to use it. I am hoping this will help DB query performance issues since the data will have better index locality. I am not sure if existing data needs to be migrated to fully utilize the benefit of UUIDv7.Hey @iuri-gg thanks for the contribution here. Unfortunately I don't think we should merge this primarily due to the readability/complexity tradeoff. The cost of changing
schema.rb->structure.sqlis pretty high and I don't think this performance improvement warrants that cost given that we're an OSS project and we want our code to be as easy to read and as predictable (for Rails devs) as possible.Pull request closed