{"id":16179702,"url":"https://github.com/mikeblum/pg-uuidv7-benchmark","last_synced_at":"2026-02-25T07:02:43.415Z","repository":{"id":202959687,"uuid":"708498546","full_name":"mikeblum/pg-uuidv7-benchmark","owner":"mikeblum","description":"Benchmark time-based UUIDv7 vs random UUIDv4 Postgres PRIMARY KEYs🐘🔑","archived":false,"fork":false,"pushed_at":"2024-12-11T23:35:39.000Z","size":42,"stargazers_count":2,"open_issues_count":2,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-12-21T08:42:03.548Z","etag":null,"topics":["postgres","postgresql","uuidv7"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mikeblum.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-10-22T18:27:41.000Z","updated_at":"2024-08-08T09:32:58.000Z","dependencies_parsed_at":"2024-06-21T17:35:18.297Z","dependency_job_id":null,"html_url":"https://github.com/mikeblum/pg-uuidv7-benchmark","commit_stats":null,"previous_names":["mikeblum/pg-uuidv7","mikeblum/pg-uuidv7-benchmark"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mikeblum%2Fpg-uuidv7-benchmark","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mikeblum%2Fpg-uuidv7-benchmark/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mikeblum%2Fpg-uuidv7-benchmark/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mikeblum%2Fpg-uuidv7-benchmark/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mikeblum","download_url":"https://codeload.github.com/mikeblum/pg-uuidv7-benchmark/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238727919,"owners_count":19520466,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["postgres","postgresql","uuidv7"],"created_at":"2024-10-10T05:43:47.857Z","updated_at":"2025-10-31T10:41:12.690Z","avatar_url":"https://github.com/mikeblum.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# pg-uuid7\n\n## Overview\n\nWith the upcoming acceptance of time-based UUIDs (v7) I wanted to validate using v4 (random) vs v7 (time-based) as primary keys under Postgres 15. \n\nIn theory we should see faster insert and lookup times for UUIDv7 primary keys compared to random UUIDv4 keys which exibit poor index locality:\n\n[CYBERTEC - Unexpected downsides of UUID keys in PostgreSQL](https://www.cybertec-postgresql.com/en/unexpected-downsides-of-uuid-keys-in-postgresql/)\n\nNormally I'd prefer the default [google/uuid](https://pkg.go.dev/github.com/google/uuid) package but it doesn't support `v7` UUIDs just yet.\n\n### Sources\n\n[UUIDv4 - RFC 4122](https://www.rfc-editor.org/rfc/rfc4122)\n\n[UUIDv7 Proposal](https://datatracker.ietf.org/doc/html/draft-peabody-dispatch-new-uuid-format-04)\n\n[Timescale - generate_series](https://www.timescale.com/blog/how-to-create-lots-of-sample-time-series-data-with-postgresql-generate_series/)\n\n## Setup\n\n- golang 1.21.x\n- postgres 15.x\n- gnu make for build tooling\n- goose for schema migrations\n- sqlc for SQL DDL\n\n`SELECT version();`\n\n\u003e PostgreSQL 15.4, compiled by Visual C++ build 1914, 64-bit\n\n### Bootstrap SQL DDL\n\n```\nmake build\n```\n\n### Bootstrap Postgres Schema\n\nExecute as the `postgres` user:\n\n```\nCREATE USER app WITH PASSWORD '????';\n\nGRANT CONNECT ON DATABASE postgres TO app;\n\nCREATE SCHEMA IF NOT EXISTS app AUTHORIZATION app;\n\nGRANT USAGE ON SCHEMA app TO app;\n\nGRANT SELECT, INSERT, UPDATE, DELETE ON ALL TABLES IN SCHEMA app TO app;\n```\n\n### Run\n\n```\nexport DATABASE_URL=\"postgres://app:????@localhost:5432/postgres?search_path=app\"\nmake run\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmikeblum%2Fpg-uuidv7-benchmark","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmikeblum%2Fpg-uuidv7-benchmark","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmikeblum%2Fpg-uuidv7-benchmark/lists"}