Skip to content

Latest commit

 

History

History
25 lines (18 loc) · 814 Bytes

uuid-postgres.md

File metadata and controls

25 lines (18 loc) · 814 Bytes

Generating ordered UUID v1

Random produces very fragmented inserts that destroy tables. Use uuid_generate_v1mc() [instead] ... the keys are seq because they're time based. So all inserts go to the same data page without random io.

CREATE EXTENSION IF NOT EXISTS "uuid-ossp";
DROP EXTENSION IF EXISTS "uuid-ossp";

SELECT uuid_generate_v1();
SELECT uuid_generate_v4();

-- Recommended!
SELECT uuid_generate_v1mc();

-- Not recommended!
CREATE EXTENSION pgcrypto;
select gen_random_uuid();

References