Why Teams Use Snowflake IDs as Primary Keys
Decoding a social-media ID is the fun part, but the reason Snowflake IDs exist is to serve as primary keys in high-throughput databases. Because the timestamp sits in the high bits, IDs are roughly time-ordered. New rows append near the right edge of a B-tree index, which keeps inserts fast and the index compact.
Random UUIDs do the opposite: every insert lands at a random spot in the index, causing page splits, cache misses, and write amplification. Switching a hot table from a random UUID key to a time-sortable Snowflake key is a common way to fix index bloat and slow writes at scale.
Where Snowflake-Style Keys Show Up
Time-ordered 64-bit keys are popular across modern distributed databases and data infrastructure:
- Sharded MySQL / Vitess: coordination-free IDs let each shard generate keys without a central sequence.
- Distributed SQL (CockroachDB, TiDB, YugabyteDB): avoids the hot-range problem that pure auto-increment keys create.
- PostgreSQL with Citus: Snowflake-style keys keep distributed inserts balanced across worker nodes.
- Cloud-managed databases (Amazon Aurora, Google Cloud SQL, Cloud Spanner): application-generated IDs scale writes without a single sequence bottleneck.