incubator-couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Hank Knight <>
Subject CouchDB: Counting Total Occurrences of Unique Items
Date Sun, 28 Jul 2013 17:22:56 GMT
This returns exactly the results I want however I am concerned with performance.

There will only ever be a few dozen unique kinds of fruit however
there will tens of thousands of occurrences of each fruit.

Can I expect this to function well when there are tens of thousands
and even hundreds of thousands of documents?

For performance reasons, should anything be moved from the reduce
function to the map function or to an additional reduce function?

Here is my map function:
function(doc) {
  if (doc.fruit) emit("fruit",doc.fruit);

Here is my reduce function:
function (keys, values, rereduce) {
    var r = {};
    for(var f=0;f<values.length;f++) r[values[f]]?r[values[f]]++:r[values[f]]=1;
    return r;

Here is a link:

View raw message