couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Brian Candler <B.Cand...@pobox.com>
Subject Re: when we should implement the rereduce in reduce function
Date Sun, 21 Jun 2009 20:21:05 GMT
On Mon, Jun 15, 2009 at 02:28:17PM +0800, hhsuper wrote:
> Hi, guys, I need some help, i want to know when we should implement the
> rereduce in reduce function?

Answer: always.

Once you get above a handful of documents you will see re-reduces taking
place. This is because reduce is done in multiple steps:

    doc \
    doc -> reduce -
    doc /          \
    doc \           \
    doc -> reduce ---rereduce --> answer
    doc /           /
    doc \          /
    doc -> reduce -
    doc /

Also: each btree node contains a bunch of documents, and the btree node also
contains a cached reduce value for that set of docs. This makes it much
cheaper for couchdb to calculate the reduce value across a range of keys; it
can use already-reduced values where available, and combine them using
rereduce.

There's more info linked from the Wiki.

Regards,

Brian.

Mime
View raw message