eventsourcing / es4j

Event capture and querying framework for Java
http://eventsourcing.com
Mozilla Public License 2.0
408 stars 25 forks source link

Problem: querying for aggregates is expensive #177

Open yrashk opened 7 years ago

yrashk commented 7 years ago

Querying for things like:

is quite expensive as it involved a lot of scanning (as can be seen in https://github.com/eventsourcing/es4j/blob/master/eventsourcing-queries/src/main/java/com/eventsourcing/queries/IsLatestEntity.java and https://github.com/eventsourcing/es4j/blob/master/eventsourcing-queries/src/main/java/com/eventsourcing/queries/LatestAssociatedEntryQuery.java)

Proposed solution: designate and formalize an aggregate indexing system.

yrashk commented 7 years ago

Proposed solution: implement aggregates as query subscribers that manipulate necessary indices manually.

Pros: relatively easy to implement, can be available very soon.

Cons: eventual index consistency — even though this will be executed before publishing future completes, it will be done after all other indices are available, causing a delay. This could be alleviated if in the future, entity subscribers will be in the same transactional context as all other updates.