Mr.Wang from Next Door
Mr.Wang from Next Door

Reputation: 14820

rereduce and group=true in CouchDB

Actually this question was raised by someone else at here https://stackoverflow.com/questions/13338799/does-couchdbs-group-true-prevent-rereduce.

But there is no convincing answer.

group=true is the conceptual equivalent of group_level=exact, so CouchDB runs a reduce per unique key in the map row set.

This is how it is explained in doc. It sounds like CouchDB would collect all the values for the same key and only reduce one time per each distinct key.

But in another article, it is said that

If the query is on the reduce value of each key (group_by_key = true), then CouchDB try to locate the boundary of each key. Since this range is probably not fitting exactly along the B+Tree node, CouchDB need to figure out the edge of both ends to locate the partially matched leave B+Tree node and resend its map result (with that key) to the View Server. This reduce result will then merge with existing rereduce result to compute the final reduce result of this key.

It sounds like rereduce may happen when group=true.

In my project, there are many documents but there are most 2 values with the same key after grouping for each distinct key. Will rereduce happen in this case?

Best Regards

Upvotes: 0

Views: 1106

Answers (1)

ddouglascarr
ddouglascarr

Reputation: 1442

Yes. Rereduce is always a possibility.

If this is a problem, there is a rereduce parameter in the reduce function, which allows you to detect if this is happening.

http://docs.couchdb.org/en/latest/couchapp/ddocs.html#reduce-and-rereduce-functions

Upvotes: 0

Related Questions