On Thu, Nov 21, 2013 at 4:47 PM, NC <naren.chain...@gmail.com> wrote: > Our use-case is very similar to what Chris has described till now. I am new > to the riak store and have a background with RDBMS. > > Going over this thread, there was a suggestion to pre-compute things. I am > trying to understand what pre-compute exactly means. Does it mean using pre > or post commit hooks to perform aggregation as different events enter our > system? Or does it mean running map reduce jobs in the background to > precompute the aggregations? > > A brief background on our use-case. We have vendors in our system that get > millions of events every week. Every two weeks, we sum the amount on all the > events for the vendor to generate an invoice. Querying millions of events > for the vendor using secondary indices or key filters doesn't seem feasible > in riak. I am wondering if we can use post-commit hooks so that as events > enter our system, we maintain a real-time account for the vendor, adding and > subtracting things on the go. When the time comes to create an invoice, we > just look at the account to find the amount to pay to the vendor.
You're on the right track. Avoiding the commit hooks might work better though. Precomputing in the content of your use case could look something like: At write time, store the event data in a key/value pair, but also create another key that has an invoice sum for a specific vendor along with a date: INVOICE_SUM:VENDOR_NAME:DATE At the end of two weeks, you can get all of the keys that make up two weeks for a specific vendor and sum them up in your client-side code: INVOICE_SUM:VENDORX:20131122 = 5 INVOICE_SUM:VENDORX:20131121 = 10 INVOICE_SUM:VENDORX:20131120 = 54 Then do the same for the next vendor. If it makes sense to roll up the sums at something larger than a day, you can do that too. > My questions are: can we even use post-commit hook in that manner where we > insert / update multiple records? Is there a different way to design such a > schema that I am missing? > > Thanks. > > > > -- > View this message in context: > http://riak-users.197444.n3.nabble.com/Using-Riak-to-perform-aggregate-queries-tp4027668p4029900.html > Sent from the Riak Users mailing list archive at Nabble.com. > > _______________________________________________ > riak-users mailing list > riak-users@lists.basho.com > http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com _______________________________________________ riak-users mailing list riak-users@lists.basho.com http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com