Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Speed up projections by only fetching projected events #681

Closed
brentsnook opened this issue Oct 31, 2019 · 1 comment · Fixed by #709
Closed

Speed up projections by only fetching projected events #681

brentsnook opened this issue Oct 31, 2019 · 1 comment · Fixed by #709

Comments

@brentsnook
Copy link

We noticed that running a projection from all streams was prohibitively slow and we were going to hand-roll our own projections then filter on event type.

After playing around I found that we could use the existing ruby event store projection with a small change:

class FilteredProjection < RubyEventStore::Projection
  def read_scope(event_store, stream, count, start)
    super(event_store, stream, count, start).of_type(*handlers.keys.uniq)
  end
end

The when methods registering handlers for the projection should tell you exactly which events to pull out.

The above isn't ideal because we are overriding methods that aren't part of the public interface. I can submit a PR when I get a chance later.

@mostlyobvious
Copy link
Member

Related to #569

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants