开发者

How long does it take to generate a CouchDB view?

I've seen it mentioned in a couple of places that it takes a while to generate a view the first time it's referenced in couchDB, but I haven't found any sort of estimate of how long it should take. More specifically, I'm trying to test a view I created and it takes so long to lo开发者_开发问答ad that I cannot tell if I screwed up the view, or if I'm just too impatient to let the view finish generating. The map function for the view is pretty simple:

function(doc){
  emit(doc.name, null);
}

I know that all the documents have a name field because I did some validation before importing them, and there is no reduce function. There are about 11,000 documents in the database, and I basically want to sort them by name.

I navigated to the view's page in futon last night and let it work for about 30 minutes without seeing any results. It seems pretty strange that it should take even that long, since a result shows up relatively quickly when the above function is used for a temporary view. Should it take this long to generate a view in CouchDB? If not, what could lead to a situation like this?


It turns out there was no problem with the map function, but the culprit was actually the reduce function. I created the view using couchapp, and the default reduce function was the following:

function(key, values, rereduce){

}

Notice that it doesn't actually return anything. Without a return value, CouchDB was apparently running the map/reduce cycle over and over again, and never actually stopping. Removing the reduce function from the view fixed the problem.

And to answer the original question, it did not take very long to generate the view. On my computer it took ~20 seconds.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜