incubator-couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mike Bannister <mikebannis...@gmail.com>
Subject Re: First doc in a group?
Date Fri, 12 Nov 2010 14:39:21 GMT
Thanks to everyone, the discussion has been very illustrative to me and
helped deepen my understanding of Couch.

On Thu, Nov 11, 2010 at 8:06 PM, Chad George <chad@mgproducts.com> wrote:

> After a little reflection, maybe my original response was a little too
> strong. You might need to use a reduce if you want the latest document for
> a
> whole set of users in a single call.
>
> If you only wanted the latest document for a single user, then the view+key
> ranges+limit=1  is definitely the best approach.
>
> Maybe Cory's idea is the best approach. A reduce function that calculates
> the latest document (maximum timestamp) and also use group=True or
> group_level=1 (depending on the final view key structure used)
>
> -Chad
>
> On Thu, Nov 11, 2010 at 6:29 PM, Mike Bannister <mikebannister@gmail.com
> >wrote:
>
> > Cool, I understand now reduce isn't right, initially posted to the list
> > because I couldn't decide that on my own.
> >
> > So what's the most efficient way to get the latest document for each
> user?
> > Seems like I shouldn't have to do one query per user but I'm open minded
> (:
> >
> > -Mike
> >
> >
> >
> > On Thu, Nov 11, 2010 at 5:52 PM, Chad George <chad@mgproducts.com>
> wrote:
> >
> > > Selecting one row in a view out of many possible isn't what reduce is
> > for.
> > >
> > > I try not to think of it as reducing a set of view results to a smaller
> > set
> > > but rather reducing each and every entry in the view to something
> > smaller.
> > >
> > > The fact that reduce gets multiple view rows to work on at once is just
> > an
> > > optimization. I think its better to think of reduce as working on
> exactly
> > > one view row at a time then rereduce the result to get final answer.
> > > On Nov 11, 2010 5:22 PM, "Mike Bannister" <mikebannister@gmail.com>
> > wrote:
> > > > Cory, cool thanks. Wasn't able to decide on my own if reducing was OK
> > for
> > > > this kind of thing.
> > > >
> > > > Robert, but I need one document for each user, wouldn't that be a
> > summary
> > > of
> > > > sorts?
> > > >
> > > > -Mike
> > > >
> > > >
> > > > On Nov 11, 2010 4:46 PM, "Cory Zue" <czue@dimagi.com> wrote:
> > > >
> > > > You could emit the users as keys, and in your reduce function just
> > > > return the latest by date.
> > > >
> > > >
> > > > On Thu, Nov 11, 2010 at 4:35 PM, Mike Bannister <
> > mikebannister@gmail.com
> > > >
> > > > wrote:
> > > >> Yeah, I'm trying...
> > >
> >
>

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