Comments (5)
Hey @leifg!
Could you share a bit more details about your use case? Reading 30k+ events sounds a lot.
Providing some setup information like DB and exact SQL which is generated would be also helpful.
event_store_events_in_streams
table keeps only event's ids, which is not enough to return read events, join to event_store_events
is required anyways at some point.
Have you tried performing any benchmarks to that point?
from rails_event_store.
Could you share a bit more details about your use case? Reading 30k+ events sounds a lot.
Sorry I should have been more clear. This is not a use case but a situation in our system. We have one stream with 30k events. This happened by accident over a couple of months. The result is: the whole system is slowing down whenever we touch this stream. There are multiple ways to optimize this in we are certainly gonna do more than one thing to get rid of this issue (one thing is probably going to get rid of the stream all together and rebuild the data).
That being said, there is one optimization that can happen within the ruby_event_store-active_record
gem
event_store_events_in_streams table keeps only event's ids, which is not enough to return read events, join to event_store_events is required anyways at some point.
That is true if you want to (efficiently) filter on attributes in the events table such as event type, timestamp etc...
However if you want to just load all events in a stream in order all you need to do is do 2 seperate queries. One to load the rows from the stream table, and then one query to query all events. This is happening via the .preload(:event)
in the first row:
irb(main):050:0> @stream_klass.where(stream: "my_stream").preload(:event)
# SELECT "event_store_events_in_streams".* FROM "event_store_events_in_streams" WHERE "event_store_events_in_streams"."stream" = $1
# SELECT "event_store_events".* FROM "event_store_events" WHERE "event_store_events"."event_id" IN ($1, $2)
So for certain query the join is unnecessary.
from rails_event_store.
Thanks for the broader explanation @leifg, it helped us understand what's the root of the problem.
The fix of issue you have exposed is on master branch already, official release should be expected soon.
Cheers!
from rails_event_store.
Hi @leifg,
We have just released version 2.8.0 containing the fix for the issue that you have reported.
We'll appreciate any feedback.
from rails_event_store.
That was quick. Thank you so much!
from rails_event_store.
Related Issues (20)
- Serializing event types from Dry::Struct events HOT 1
- ActiveJobScheduler does not stringify payload keys and triggers warning in Sidekiq
- Redesign event page HOT 2
- Test on truffleruby HOT 2
- Use of mutation testing in rails_event_store - Help needed
- ActiveRecord and the need of non-serialized data and metadata for JSONB HOT 1
- Repository for MySQL 8.0 using NOWAIT (and possibly PostgreSQL) HOT 1
- Generate test workflow YAMLs from templates
- Unable to update to rails_event_store 2.8 HOT 3
- RubyEventStore::Projection does not yield events in deterministic order when using multiple streams HOT 2
- Improve RES projections
- Migration guide to RailsEventStore::JSONClient HOT 3
- Create new release for `ruby_event_store-rom` HOT 1
- can't write unknown attribute `event_id` HOT 2
- ruby_event_store-browser 2.10 undefined method `match?' for nil:NilClass HOT 4
- Making the broker configurable HOT 3
- Unsupported adapter when running migration (2.11.1) HOT 6
- Rspec issue when testing with have_subscribed_to_events HOT 5
- NoMethodError when using `RubyEventStore::RSpec::Publish` matcher with `InMemoryRepository` and preceding events HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rails_event_store.