Using just enough CQRS
The Store Management module has a number of existing queries in the application. Some we may be able to serve from the event store, such as GetProduct()
and GetStore()
, but the others, such as GetParticipatingStores()
or GetCatalog()
, would require scanning the entire table to rebuild every stream, and then we would filter a percentage out.
When we created the events table in the previous section, we left the existing tables alone. This was a tiny bit of cheating on my end. Although I knew the tables would be used again for our read models, it might not always be practical to reuse old tables. In most cases, the tables that support your read models should be specifically designed to fulfill requests as efficiently as possible. The tables that are left over after a refactoring might not be suitable for that task.
We could also use entirely new tables, use a new database, and even do more beyond using different read models. Right now, our only need is to...