couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mark Hahn <m...@hahnca.com>
Subject Re: Get total number of documents in view, without getting all documents
Date Fri, 22 Jun 2012 15:50:40 GMT
Use map/reduce with a simple sum function.  Then the number will always be
available.

On Fri, Jun 22, 2012 at 6:17 AM, Daniel Gonzalez <gonvaled@gonvaled.com>wrote:

> On Fri, Jun 22, 2012 at 2:05 PM, Dave Cottlehuber <dave@muse.net.nz>
> wrote:
>
> >
> > Either its retrieving all documents, or the view is being built while you
> > wait.
> >
> > Add limit=0 to your view parameters, to address the first issue.
> >
> > I guess you want to know the current # of documents, so if the view
> > hasn't been built yet, or needs updating you will need to wait. If you
> > are OK with an older result then you can use stale=ok.
> >
> > A+
> > Dave
> >
>
> Thanks, the limit=0 parameter is working. I thought that putting a limit
> parameter would affect the total_rows parameter returned by the view. I see
> now that total_rows refers to the number of documents in the view, not just
> the returned ones. Which makes sense, obviously. I was just very confused.
>

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