couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Arun Thampi <>
Subject Hitting the reduce_limit
Date Tue, 18 Aug 2009 15:57:59 GMT
Hi guys - I have the following reduce function which returns a result object
where each value is an object (instead of an array). Basically I'm trying to
get the text value of a thread and the number of associated replies. However
when the length of the string which is stored in the text property is large,
I hit the reduce_limit. The same thing happens when I try to add more
properties to the result object. The view is queried like so:
guess my question boils down to whether this is a 'good' reduce function? I
remember Jan mentioning in another thread that we should not be converting
tall lists to wide lists, but since the result of this reduce function
contains objects instead of arrays of objects, I'm not sure whether its the
same as converting from tall -> wide lists. Please correct me if I've missed
something. (For now i've disabled reduce_limit and it seems to be working

As always, thanks for the help!


Reduce Function:

function(keys, values, rereduce) {
  var result = { num_replies: 0, text: "" };

  if(rereduce) {
    for(idx = 0; idx < values.length; idx++) {
      result.num_replies += values[idx].num_replies;
      result.text = values[idx].text;
  } else {

    for(idx = 0; idx < values.length; idx++) {
      if(values[idx].type == 'thread') {
        result.text = values[idx].text;
      } else if(values[idx].type == 'reply') {
        result.num_replies += 1;

  return result;

It's better to be a pirate than join the Navy - Steve Jobs

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message