Return-Path: X-Original-To: apmail-couchdb-user-archive@www.apache.org Delivered-To: apmail-couchdb-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 3742610146 for ; Sun, 28 Jul 2013 17:23:30 +0000 (UTC) Received: (qmail 84356 invoked by uid 500); 28 Jul 2013 17:23:29 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 83954 invoked by uid 500); 28 Jul 2013 17:23:23 -0000 Mailing-List: contact user-help@couchdb.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@couchdb.apache.org Delivered-To: mailing list user@couchdb.apache.org Received: (qmail 83946 invoked by uid 99); 28 Jul 2013 17:23:23 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 28 Jul 2013 17:23:23 +0000 X-ASF-Spam-Status: No, hits=-0.5 required=5.0 tests=FREEMAIL_ENVFROM_END_DIGIT,RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of hknight555@gmail.com designates 209.85.219.44 as permitted sender) Received: from [209.85.219.44] (HELO mail-oa0-f44.google.com) (209.85.219.44) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 28 Jul 2013 17:23:17 +0000 Received: by mail-oa0-f44.google.com with SMTP id l20so7699852oag.17 for ; Sun, 28 Jul 2013 10:22:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=DcPafC2KFYdJbmLRMMrT7islRY+sUIlt1OH2wrNj7wk=; b=Jm7u3DmQFOaoDhqxKPAbG4HKEvifLtRaVIKs4kaJVI9iqLOzF5oZWhgmoUjgia2aEV QQRJrLGXOXEpE+Ooin7tDHiBK6mwRw6g2gDRFJrkQC1MGEcY0FjPDp2mnZOwZ3zssFOC zg3ZT3tPjOf2FhUh0/xek8DvO95LBw3W40Ai+p+A7s6ybfw6qtV8hYxt8Xknh/3jQP4j fCsikUsaksYe7Z7Pi4VLDgojnbommYz5w1qckwbjIk6lscCvqWKqqi/A//gI0hbaVTCD YTytutQ/5SVXuEOv2vUB1AUB6AWAsWAWbZD/gnEy/eESEhQb41FhOUP2Gsi+NXicJ2VE ldFA== MIME-Version: 1.0 X-Received: by 10.60.135.167 with SMTP id pt7mr55758100oeb.59.1375032176347; Sun, 28 Jul 2013 10:22:56 -0700 (PDT) Received: by 10.76.0.167 with HTTP; Sun, 28 Jul 2013 10:22:56 -0700 (PDT) Date: Sun, 28 Jul 2013 14:22:56 -0300 Message-ID: Subject: CouchDB: Counting Total Occurrences of Unique Items From: Hank Knight To: user@couchdb.apache.org Content-Type: text/plain; charset=ISO-8859-1 X-Virus-Checked: Checked by ClamAV on apache.org 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