couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Apache Wiki <>
Subject [Couchdb Wiki] Update of "Introduction to CouchDB views" by RobertNewson
Date Sun, 30 Aug 2009 17:20:25 GMT
Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Couchdb Wiki" for change notification.

The following page has been changed by RobertNewson:

  === Reduce Functions ===
+ Reduce is a powerful feature of CouchDB but is often misused which leads to performance
problems. From 0.10 onwards, CouchDB uses a heuristic to detect reduce functions that won't
scale to give the developer an early warning. A reduce function must reduce the input values
to a smaller output value. If you are building a composite return structure in your reduce,
or only transforming the values field, rather than summarizing it, you might be misusing this
feature. See [:#reduced_value_sizes] for more details.
  If a view has a reduce function, it is used to produce aggregate results for that view.
A reduce function is passed a set of intermediate values and combines them to a single value.
Reduce functions must accept, as input, results emitted by its corresponding map function
'''as well as results returned by the reduce function itself'''. The latter case is referred
to as a ''rereduce''.
  Here is an example of a reduce function:
@@ -272, +274 @@

  f(Key, Values) == f(Key, [ f(Key, Value0), f(Key, Value1), f(Key, Value2), ... ] )
+ [[Anchor(reduced_value_sizes)]]
  === Reduced Value Sizes ===
  As CouchDB computes view indexes it also calculates the corresponding reduce values and
caches this value inside each of the btree node pointers. This scheme allows CouchDB to reuse
reduced values when updating the btree. This scheme requires some care to be taken with the
amount of data returned from reduce functions.

View raw message