UUID Use Case

UUID Shard Key

A shard key decides which partition a row lives on. Random UUIDs distribute writes uniformly; time-ordered ones can pile recent writes onto one shard.

Even spreadv4 recommendedAvoids hotspots

Generated locally with the Web Crypto API — nothing leaves your browser.

What Is UUID Shard Key?

How to generate

  1. Use v4 for the shard/distribution key.
  2. Hash the UUID or use it directly as the partition discriminant.
  3. Monitor per-shard size to confirm an even split.

Use Cases

Code Examples

JavaScript
const id = crypto.randomUUID();
Python
import uuid
id = uuid.uuid4()

Frequently Asked Questions

Why use v4, not v7, for a shard key?
v7's timestamp makes consecutive IDs land on nearby partitions, creating hotspots. v4's randomness spreads load evenly.
Can I shard by a v7 primary key?
You can, but expect recent rows to concentrate on one shard. Keep a separate v4 distribution key if write spread matters.

Related tools