Yes, Tomas Vondra created a sequential uuid extension for PostgreSQL based on the MSSQL newsequentialid only less predictable.
Primary key's are used by indexes to find data quicker as they are sequential so by using completely random UUID's they miss the advantage.
Using perfectly sequential UUID become predictable and works against the original idea of using UUID's in that they are globally unique.
Vondra's extension is using bits of both worlds: " ... Instead of generating a perfectly sequential prefix, the value is sequential for a while, but also wraps around once in a while. The wrapping eliminates the predictability..."
How to install it into your PostgreSQL:
Prerequires on Ubuntu:
postgresql-server-dev-11
Install:
git clone https://github.com/tvondra/sequential-uuids.git
cd sequential-uuids/
make
sudo make install
inside PostgreSQL:
CREATE EXTENSION sequential-uuids;
Make it work by example:
DROP SEQUENCE IF EXISTS tablename_names_seq;
DROP TABLE IF EXISTS names;
CREATE SEQUENCE tablename_names_seq AS integer;
CREATE TABLE names(id uuid NOT NULL DEFAULT uuid_sequence_nextval('tablename_names_seq'::regclass),name varchar(40));
INSERT INTO names (name) VALUES ('William McKinley'),('Theodore Roosevelt'),('William Taft'),('Woodrow Wilson'),('Warren Harding'),('Calvin Coolidge'),('Herbert C. Hoover'),('Franklin Delano Roosevelt'),('Harry S Truman'),('Dwight David Eisenhower'),('John Fitzgerald Kennedy'),('Lyndon Baines Johnson'),('Richard Milhous Nixon'),('Gerald R. Ford'),('James (Jimmy) Earl Carter, Jr.'),('Ronald Wilson Reagan'),('George H. W. Bush'),('William (Bill) Jefferson Clinton'),('George W. Bush'),('Barack Obama'),('Donald Trump');
...will create in my case:
db=# select * from names;
id | name
--------------------------------------+----------------------------------
00005b41-8b07-3daa-216e-30b3e8177705 | William McKinley
00004ce4-1183-7689-47a0-a56d7e8e987c | Theodore Roosevelt
...
000042a0-2e72-c92b-6d61-7a79a5bf3b7e | Barack Obama
00002d51-34c3-a682-12ab-0d6287394899 | Donald Trump
source:
https://github.com/tvondra/sequential-uuids
https://www.2ndquadrant.com/en/blog/sequential-uuid-generators/