couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Julian Stahnke <>
Subject View output slow
Date Fri, 12 Mar 2010 13:10:54 GMT

I have a problem with a view being slow, even though it’s indexed and cached and so on.
I have database of books (–120,000 documents) and a map/reduce function that counts how
many books there are per author. I’m then calling the view with ?group=true to get the list.
I’m neither emitting nor outputting any actual documents, only the counts. This results
in an output of about 78,000 key/value pairs that look like the following: {"key":"Albert

Now, even when the view is indexed and cached, it still takes 60 seconds to receive the output,
using PHP’s cURL functions, the browser, whatever I’ve tried. Getting the same output
served from a static file takes only a fraction of a second.

When I set limit=100, it’s basically instantaneous. I want to sort the output by value though,
so I can’t really limit it or use ranges. Trying it with about 7,000 books, the request
takes about 5 seconds, so it seems to be linear to the number of lines being output?

I’m using CouchDB 0.10.1 (the one that’s in homebrew) on a 2006 MacBook Pro.

Am I doing anything wrong, or should this really take so long? I wasn’t able to find any
information about this—only about indexing being slow, but that doesn’t seem to be my

Maybe I should also mention that I’m an interaction design student who used to be a front-end
dev, but not a ‘real’ programmer.

Thanks for any help!


For reference, the map function:

function (doc)
    if ( {
		for (i = 0; i <; i++) {
			emit([i], 1);
    } else {
        emit(null, 1);        

The reduce function: 

function (keys, values, rereduce)
    return sum(values);

Some sample output:

{"key":"... Hans Arp ... /Konzept: Hans Christian Tavel .../","value":1},
---more rows---
{"key":"Zwi Erich Kurzweil","value":1}
View raw message