Return-Path: Delivered-To: apmail-couchdb-user-archive@www.apache.org Received: (qmail 458 invoked from network); 22 Nov 2009 02:01:23 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 22 Nov 2009 02:01:23 -0000 Received: (qmail 70313 invoked by uid 500); 22 Nov 2009 02:01:22 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 70247 invoked by uid 500); 22 Nov 2009 02:01:21 -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 70237 invoked by uid 99); 22 Nov 2009 02:01:21 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 22 Nov 2009 02:01:21 +0000 X-ASF-Spam-Status: No, hits=-2.6 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: apache.org Received-SPF: neutral (athena.apache.org: local policy) Received: from [83.97.50.139] (HELO jan.prima.de) (83.97.50.139) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 22 Nov 2009 02:01:19 +0000 Received: from [10.0.1.3] (f053038118.adsl.alicedsl.de [::ffff:78.53.38.118]) (AUTH: LOGIN jan, TLS: TLSv1/SSLv3,128bits,AES128-SHA) by jan.prima.de with esmtp; Sun, 22 Nov 2009 02:00:56 +0000 Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Apple Message framework v1077) Subject: Re: Counting unique items From: Jan Lehnardt In-Reply-To: <2f84d03e0911211309w58359625na39a3af812200fa@mail.gmail.com> Date: Sun, 22 Nov 2009 03:00:23 +0100 Content-Transfer-Encoding: quoted-printable Message-Id: References: <2f84d03e0911211309w58359625na39a3af812200fa@mail.gmail.com> To: user@couchdb.apache.org X-Mailer: Apple Mail (2.1077) On 21 Nov 2009, at 22:09, Guy Moulton wrote: > Hello, >=20 > I'm trying to get a count of the number of unique items in a database. > Documents look like this: >=20 > Item: Item_A, User: Dave > Item: Item_A, User: John > Item: Item_A, User: Jane > Item: Item_B, User: John > Item: Item_B, User: Anne >=20 > In the above example, I'd like to know that there are 2 items. So > far, I have a map/reduce that produces one view row for each kind of > item (similar to the example on the wiki) : >=20 > key: "Item_A", value:"Null" > key: "Item_B", value:"Null" >=20 > So the number I need is the number of rows in the view. >=20 > According to the wiki, if I pass limit=3D0, it should give me the > meta-data, but this doesn't seem to work on views that have a reduce > function. I don't want to count rows in the client as there could > potentially be a very large number. >=20 > Any ideas would be very much appreciated. Hi Guy, this might help you: = http://books.couchdb.org/relax/reference/views-for-sql-jockeys#Get%20Uniqu= e%20Values%20(SELECT%20DISTINCT%20field%20FROM%20table) Cheers Jan --