couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dave Cottlehuber <>
Subject Re: Get total number of documents in view, without getting all documents
Date Fri, 22 Jun 2012 12:05:57 GMT
On 22 June 2012 13:47, Daniel Gonzalez <> wrote:
> Hello,
> I have a view which currently contains around 50 thousand documents.
> I need to display the exact number of documents. For that I access the view
> and take a look at the total_rows field.
> I am doing this in pyhton, with python-couchdb, like this:
> View(<my parameters>).total_rows
> The problem is that this is taking a long time. It seems it is getting all
> documents-
> I am not sure whether this expected behaviour, or maybe I am doing
> something wrong.
> Is there a way to get the total number of documents in a view without
> getting the documents themselves?
> BR,
> Daniel

Either its retrieving all documents, or the view is being built while you

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.


View raw message