1
votes

I'm trying understand CQRS to see if it can help out in an reporting environment.

Problem: An CQRS designed system is already in production, happily generating commands, events and updating the necessary query views. A new report is required. This report takes a number of parameters; Start Date, End Date, Product Type, and Product Category.

How do I generate the aggregate views for:

  • A query store that will initially be empty
  • And, can pass parameters with very different values

Do I try and solve this using a CQRS approach, or is there a better alternative?

Thanks

2

2 Answers

2
votes

If it is not reasonable to precompute all your report data into flat view, then just don't do that. You may want to join a bunch of tables for your report. It's your decision what can be precomputed, and what is not worth it (cpu, storage considerations).

In your particular case (StartDate, EndDate,..) - i can't see what is the problem to generate a single ViewModel table for it, and just query directly against the parameters.

2
votes
  1. Figure out which events are required to gather all report data.
  2. Query all those events, republish them to the endpoint that handles updating the new report table(s).
  3. Wait until all events have been processed.
  4. Put some indexes on the columns that will function as report query criteria.

Done!