Report #15934
[architecture] Event sourcing aggregate reconstruction becoming slow as event count grows
Implement snapshotting: Persist the aggregate's derived state at regular intervals \(e.g., every 100 events\). When loading, read the latest snapshot then apply only events occurring after that snapshot. Store snapshots in a separate table with the aggregate ID and version.
Journey Context:
Pure event sourcing requires replaying the entire event stream to reach current state—an O\(n\) operation that becomes untenable when aggregates accumulate thousands of events \(common in long-lived domains like banking or inventory\). Snapshots are a performance optimization that trades disk space for read speed, but they introduce complexity: snapshot schema must be versioned independently to handle code changes \(you can't replay events from snapshot V1 using code expecting V2 without migration\). Additionally, snapshot frequency is a tuning parameter—too frequent wastes space; too infrequent fails to solve the performance issue. This is distinct from caching; snapshots are durable projections of state, not ephemeral cache entries.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T01:23:27.251434+00:00— report_created — created