What is the difference between UUID v4 and UUID v7?
Version 4 is 122 bits of randomness and says nothing about when it was made. Version 7, standardised in RFC 9562 (2024), starts with a 48-bit Unix timestamp in milliseconds, so new IDs sort after old ones. That keeps B-tree indexes compact and inserts fast, which is why v7 is the better default for database primary keys.