incubator-couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jesse Hallett <halle...@gmail.com>
Subject Re: Tree structure: how to calculate branch node sum, using results from a view that calculates leaf node sums.
Date Sun, 06 Sep 2009 03:19:24 GMT
On Sat, Sep 5, 2009 at 8:42 AM, Metin Akat<akat.metin@gmail.com> wrote:
> On Sat, Sep 5, 2009 at 10:20 AM, Chris Anderson<jchris@apache.org> wrote:
>> On Fri, Sep 4, 2009 at 11:34 PM, Metin Akat<akat.metin@gmail.com> wrote:
>>> One way I can think of is to bulk update all transactions "belonging"
>>> to a leaf account when moving that leaf account around.
>>> I can live with having to wait some time till this gets executed.
>>> Is this "bad thinking" or is it OK to some extent?
>>>
>>
>> It can be problematic if you need ACID compliance as bulk updates
>> aren't transactional. (Especially consider what can happen during
>> replication.)
>>
>> This can often be remedied in your app model, but this is can get complex.
>>
>
> So this probably means that the least problematic way to go would be
> if I calculate aggregate balances client side.
> OK, for now I don't plan having millions of accounts, so I'll choose
> this way after all.
>

Why not record the account hierarchy with each transaction and think
of that as a snapshot of the hierarchy when the transaction occurred?
You get a little extra historical data that way.  You can emit a view
row for every account in the lineage so that when you calculate
account balances you only need to use the account id as the key.  So
it does not matter if the hierarchy in the transaction does not match
the current hierarchy.

Mime
View raw message