You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@couchdb.apache.org by Sam Raker <sa...@gmail.com> on 2014/11/30 01:52:09 UTC

Infinite resets hanging views

I'm trying to run a temporary view on a big-ish db (> 1000 docs). I realize
temporary views are slow, but the view seems to hang forever. The view I'm
running:

# map function
function(doc) {
  emit(doc, doc.tweets);
}


# reduce function
function(keys, values, rereduce) {
var arr, sum = 0;
for (arr in values) {
sum = sum + arr.length || 1;
}
return sum;
}

In my logs, I keep seeing lines like this, over and over and over again:

[Sun, 30 Nov 2014 00:15:33 GMT] [debug] [<0.16471.7>] OS Process
#Port<0.162087> Input  :: ["reset",{"reduce_limit":true,"timeout":5000}]


I'm not sure if this is to be expected, and my view is just taking a really
long time, or if there's something wrong with my view or settings.



Thanks,

-sam

Re: Infinite resets hanging views

Posted by Mike Marino <mm...@gmail.com>.
Hi Sam,

I would have 2 further tips:

1.  I would go further and say: Never emit the full doc in a map function.
You can get the full doc by using the include_docs flag when querying the
view. If you need a key that only refers to a single doc, use the _id of
the doc.

2.  Don't write your own reduce functions, use couch's built in, erlang
functions (See http://wiki.apache.org/couchdb/Built-In_Reduce_Functions).
You will save yourself a lot of headaches and you will not match the
performance of these functions. In your case, _count is probably what you
want, though you probably don't even need a reduce function with such an
index (as Aurelien essentially pointed out). Handle the case where
doc.tweets doesn't exist in your map function:

emit(doc._id, doc.tweets || []);

Cheers,
Mike



Am Sonntag, 30. November 2014 schrieb Aurélien Bénel :

> Hi Sam,
>
> > # map function
> > function(doc) {
> >  emit(doc, doc.tweets);
> > }
>
> Your map function is really weird.
>
> Think of `map` as a way to create secondary indexes.
>
> 1. An index on the whole document doesn't make much sense.
> 2. Moreover, at query time, if you want to get data that are in the same
> document,
> you don't need map/reduce at all. Just create a `show` function.
>
>
> Regards,
>
> Aurélien

Re: Infinite resets hanging views

Posted by Aurélien Bénel <au...@utt.fr>.
Hi Sam,

> # map function
> function(doc) {
>  emit(doc, doc.tweets);
> }

Your map function is really weird.

Think of `map` as a way to create secondary indexes.

1. An index on the whole document doesn't make much sense.
2. Moreover, at query time, if you want to get data that are in the same document, 
you don't need map/reduce at all. Just create a `show` function.


Regards,

Aurélien