couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Brian Candler <>
Subject Re: reduce limit
Date Tue, 09 Jun 2009 09:31:36 GMT
On Sat, Jun 06, 2009 at 09:52:18AM +0200, Benoit Chesneau wrote:
> This morning I hit reduce limit while trying to recreate a tree from
> documents containing a "parent" member. I tried first to create an
> index of documents and add to value a children member :
> function(keys, values, rereduce) {
>   var idx_comments = {};
>   if(!rereduce) {
      ... snip
>   } else {
>     return values;
>   }

I'm not sure exactly what you're trying to achieve here, but it can't be
right like that. Unless you're working on a tiny dataset of a handful of
documents, reducing is a multi-step process. You must be able to reduce down
in a tree, combining a set of previously-reduced values.

And in any case: as far as I can see, your code under if(!rereduce) doesn't
return anything!

Can you explain what you want to get out from the reduce value?

Maybe you're trying to build a tree of

    "id1": {parent:"parent_id", children:["id","id","id"],
    "id2": {parent:"parent_id", children:["id","id","id"],

If so, that's not a "good" reduce function. It will be extremely inefficient
when you have a large dataset, because the intermediate and final reduce
values will be very large.

You would be much better off building the tree in the client. Given a
suitable view which just emits parent_id, the data transferred to the client
will be small (smaller than the reduce view, in fact)



View raw message