Return-Path: Delivered-To: apmail-incubator-couchdb-user-archive@locus.apache.org Received: (qmail 84535 invoked from network); 27 Aug 2008 01:19:56 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 27 Aug 2008 01:19:56 -0000 Received: (qmail 65609 invoked by uid 500); 27 Aug 2008 01:19:53 -0000 Delivered-To: apmail-incubator-couchdb-user-archive@incubator.apache.org Received: (qmail 65585 invoked by uid 500); 27 Aug 2008 01:19:53 -0000 Mailing-List: contact couchdb-user-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: couchdb-user@incubator.apache.org Delivered-To: mailing list couchdb-user@incubator.apache.org Received: (qmail 65574 invoked by uid 99); 27 Aug 2008 01:19:53 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 26 Aug 2008 18:19:53 -0700 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: local policy) Received: from [206.210.85.213] (HELO smtp1.nviznit.com) (206.210.85.213) by apache.org (qpsmtpd/0.29) with SMTP; Wed, 27 Aug 2008 01:18:52 +0000 Received: from [192.168.0.129] (c-71-60-56-89.hsd1.pa.comcast.net [71.60.56.89]) by smtp1.nviznit.com (Postfix) with ESMTPSA id 854721BD898 for ; Tue, 26 Aug 2008 17:32:16 -0400 (EDT) Message-ID: <48B4AB94.7060509@visn.biz> Date: Tue, 26 Aug 2008 21:19:16 -0400 From: Joel Reed User-Agent: Thunderbird 2.0.0.16 (X11/20080725) MIME-Version: 1.0 To: couchdb-user@incubator.apache.org Subject: Re: using reduce to get SQL distinct like results References: <48B46F44.2030309@visn.biz> <20080826215316.GF2126@ginosko.ndrix.org> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org Chris Anderson wrote: > I would avoid using a reduce at all in this case, and just request the > key-range corresponding to the particular user directly from the map. > OK, but just to be clear, the data set I want to display would be something like User 1 -- Dates: 11/02/2003, 12/02/2004, 1/02/2005 User 2 -- Dates: 3/12/2004, 10/02/2005, 1/02/2006 User 3 -- Dates: 4/12/2003, 6/02/2006, 1/02/2006 etc... You wouldn't advise me to make multiple calls to the same view for each user would you? Once to get list of all users, then once for every user? I was thinking that maybe in this case I should be using a reduce function. What would you advise? jr > You'll get all the information you need, and little extraneous > information. You can then munge the data into whatever shape you need > in your application. However, I bet you won't need to do much munging. > > "all": { > "map": "function(doc) { emit(doc.User, doc.Date); }" > } > } > > Reduce should be reserved for when you want to aggregate a scalar > value from a set of map rows. Eg, the number of messages a user > received in a given month, or some such. When you merely want all the > data from a map, about a given key, just query the map. > > Chris > > > >