Skip reindexing when commit() creates a new write stream#300
Merged
Conversation
… new write streams Agent-Logs-Url: https://github.com/albe/node-event-storage/sessions/c20509ac-7d15-4180-a14a-d6537b437e62 Co-authored-by: albe <4259532+albe@users.noreply.github.com>
Copilot created this pull request from a session on behalf of
albe
April 30, 2026 14:39
View session
Copilot AI
added a commit
that referenced
this pull request
May 1, 2026
Agent-Logs-Url: https://github.com/albe/node-event-storage/sessions/c52381ea-b3e2-442c-8048-04072f3e7797 Co-authored-by: albe <4259532+albe@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
createEventStreamalways reindexes the full store when creating a new stream. For ad-hoc read streams this is necessary, but for write streams created implicitly bycommit(), no existing event can ever match the brand-new stream name — reindexing is wasted work.Changes
WritableStorage.ensureIndex(name, matcher, reindex = true)— addedreindexflag; whenfalse, skips theforEachDocumentscan and registers the new index empty.EventStore.createEventStream(streamName, matcher, reindex = true)— threads the flag through toensureIndex. Public default remainstrue, preserving existing behaviour for ad-hoc read streams.EventStore.commit()— passesreindex: falsewhen auto-creating a write stream, since uniqueness of the stream name guarantees zero historical matches.