Report #74229
[architecture] Event sourcing aggregate replay performance degradation over time
Implement versioned snapshots every N events \(e.g., 100\) as immutable records in a separate snapshot table; load the latest snapshot then replay only events occurring after its version.
Journey Context:
Replaying thousands of events to rebuild an aggregate becomes exponentially slower as the event log grows. Naive approaches try to update a single snapshot row in place, which destroys the append-only audit trail and creates write contention. The robust pattern stores snapshots as immutable facts \(aggregate state \+ version\) keyed by aggregate ID. When loading, fetch the max version ≤ current snapshot version, then apply only subsequent events. This trades storage for idempotency and speed.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T07:11:36.740057+00:00— report_created — created