Skip to content

umang-sinha/postgres-uuid-benchmark

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

postgres-uuid-benchmark

This repository benchmarks the performance of inserting and querying 10 million rows in PostgreSQL using UUIDv4 and UUIDv7 as primary keys. It measures insertion time to help determine which version of UUID performs better under realistic database workloads.

What This Does

  • Generates 10 million rows of random data with UUIDv4 and UUIDv7 as primary keys.

  • Inserts them into two separate PostgreSQL tables: uuid_v4_test and uuid_v7_test.

  • Measures and prints time taken to generate and insert UUIDs

Setup Instructions

  1. Clone the Repo
git clone https://github.com/your-username/uuid-benchmark.git
cd uuid-benchmark
  1. Create the Tables in PostgreSQL

Make sure you have a local PostgreSQL instance running and a database named uuid_benchmark. Create the required tables:

CREATE TABLE uuid_v4_test (
  id UUID PRIMARY KEY,
  payload TEXT
);

CREATE TABLE uuid_v7_test (
  id UUID PRIMARY KEY,
  payload TEXT
);
  1. Run the Benchmark
go run main.go

This will:

  • Generate UUIDv4 and UUIDv7 datasets

  • Insert them into the database in batches of 10,000

  • Print time taken for each insertion

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages