Microsoft SQL Server offers the
NEWID command to generate a new GUID (the Microsoft version of UUID) value that can be used as a primary key value (in their
uniqueidentifier data type). These are not sequential in nature, so updating an index can be inefficient.
Alternatively, MS SQL Server offers the
NEWSEQUENTIALID command. To quote their documentation:
Creates a GUID that is greater than any GUID previously generated by this function on a specified computer since Windows was started. After restarting Windows, the GUID can start again from a lower range, but is still globally unique. When a GUID column is used as a row identifier, using NEWSEQUENTIALID can be faster than using the NEWID function. This is because the NEWID function causes random activity and uses fewer cached data pages. Using NEWSEQUENTIALID also helps to completely fill the data and index pages.
Is there a way to get the more efficiently-indexed UUID in Postgres?