On Tue, Jan 15, 2013 at 5:12 PM, Werner Clausen <
item...@hotmail.com> wrote:
> Hi Benny (and others)
>
> Thanks for your replies.
>
> The reason for having one table per aggregate type, is that we expect around
> 100 million events (maximum, most customers would just have 20+). For this
> reason we have implemented the EventStore as one table per context. And
> while this seemed architectural correct for a while, trouble came when
> someone wanted to read an aggregate from another context. This wasn't
> possible as we have no configuration to support that AggregateType1 belongs
> to Table1 etc. But this should be possible right?
I dont think you should be able to do this ... id use the read model
if I absolutely have to , to me the idea of context is isolation and
in most samples they are a dll , with only the commands and
externally available events being public.
>
> From there, it didn't take too long for someone to suggest that we split
> everything. That way, we would be fairly sure not to hit any performance
> barrier due to large event tables. Searching the matter and it turned out,
> that quite a few ppl have done so - at least in theory. This is the cause
> for my concerns, and this thread.
SQL likes deep tables with few fields , its really no more work for
the db than multiple tables since you should not be doing any get *
From table ...if you were going to hit performance issues surely
caching is a better first step (and then into partitioning etc) ,
though further steps should rarely be needed since the entire
write domain is often only 1 "client".
>
> But I will take your advices as my next pointer. This means however, that
> I'm caught between a rock and a hard place. Either I go with 1 event table
> and hope this doesn't perform crazy with 100+ records. Or I keep the current
> "one bc = one table" and make some ugly crappy configuration to support
> reading from other contexts.
In the majority of cases it will perform fine with millions of
records ( and you can get to 100M+ easy enough ) .. If you expect
lots of reads eg lots of commands to the same aggregates rather than
new aggregates and dont have a distributed environment than cache if
you find poor performance it should remove most ( often 90%+) of the
read traffic.
>
> The thing is, if at some point in time I wanted to split the eventtable,
> this would be a hard job because we do not store metadata (yet). This means
> that we have no way to determine the event namespace/type just by looking at
> the database. Should we store these metadata in a sep. table at all costs?
I think the real problem here is you are getting aggregates from
other contexts . The whole point of a context is isolation and
different views of the same aggregate eg carSale is different for the
salesman , service and leasing .And then contexts communicate via
events ( or you can push via commands) and the event and command
shoudl have all the data they need not an Id .. If your fetching
aggregates from other contexts than you may as well have a single
context .
Why split the table ? .. To me the biggest danger of splitting the
event table is focus .. it may lead to developers doing readtype
queries on the event store The focus should be on the query side.
All you should be doing is query by type and id ,maybe occasionally
filtered by date (but this can be done in code) and inserts. So you
are looking at an indexed lookup and an insert , DBs should do this
very fast , no table scans , little contention etc , and repeats of
the same queries so heavily cached etc .
Ben