Postgres 18 to Feature UUIDv7: No More ID Sorting Headaches in Tests

2025-01-02

PostgreSQL is set to include UUIDv7 support in version 18. This improved UUID generation method retains the randomness benefits of UUIDv4 while ensuring monotonically increasing IDs within a single Postgres backend. This is achieved by incorporating a timestamp and a 12-bit sub-millisecond counter. Testing is greatly simplified as test data is automatically ordered, eliminating the need for manual sorting and improving test efficiency and reliability. While monotonicity isn't guaranteed across backends, it's sufficient for most testing scenarios. This enhancement is slated for release in late 2025 with PostgreSQL 18.

Development