Wire snowflake ID generator into all stores as default Event.ID #44

Closed
opened 2026-02-20 10:06:53 +00:00 by ash · 0 comments
Owner

Problem

Snowflake generator exists in id/ package but is NOT used by any store. Stores use garbage IDs:

  • pgstore: fmt.Sprintf("%d", id)
  • natsstore: fmt.Sprintf("%s@%d", streamID, version)
  • dlq: fastID() (random)

This defeats the purpose of having snowflake IDs — no time-ordering, no B-tree optimization.

Fix

  • Create a default global Snowflake generator (instance 0)
  • All stores: if Event.ID is empty on Append, auto-generate with snowflake
  • Configurable: user can provide their own generator (for clustering with instance IDs)
  • Store the int64 as the ID, not a string

Why it matters

  • Postgres: sequential int64 inserts are 10-100x faster than random string UUIDs
  • B-tree index stays compact and ordered
  • Distributed: each instance uses different instance ID, no conflicts
## Problem Snowflake generator exists in `id/` package but is NOT used by any store. Stores use garbage IDs: - pgstore: `fmt.Sprintf("%d", id)` - natsstore: `fmt.Sprintf("%s@%d", streamID, version)` - dlq: `fastID()` (random) This defeats the purpose of having snowflake IDs — no time-ordering, no B-tree optimization. ## Fix - Create a default global Snowflake generator (instance 0) - All stores: if Event.ID is empty on Append, auto-generate with snowflake - Configurable: user can provide their own generator (for clustering with instance IDs) - Store the int64 as the ID, not a string ## Why it matters - Postgres: sequential int64 inserts are 10-100x faster than random string UUIDs - B-tree index stays compact and ordered - Distributed: each instance uses different instance ID, no conflicts
ash closed this issue 2026-02-20 10:15:09 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
ash/eskit#44
No description provided.