couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Robert Newson <rnew...@apache.org>
Subject Re: Hitting reduce_limit with "good" reduce function
Date Thu, 11 Apr 2013 18:21:47 GMT
That's not "good" enough for a reduce. A reduce function has to return
a value *smaller* than the input values, and preferably a lot smaller.
Returning something as large as a full document is among the set of
things reduce_limit is trying to discourage.

For this problem, you should emit your timestamps in the map phase and
use endkey and limit to find the latest. It's not a reduce problem.

B.

On 11 April 2013 14:06, Michael Jackson <mjijackson@gmail.com> wrote:
> Hi,
>
> I'm currently getting the "Reduce output must shrink more rapidly" error
> with what I believe is a "good" reduce function. When I checked the
> default.ini config file to tweak the reduce_limit setting, it told me to
> ping the mailing list "so we can fine tune the heuristic", so here I am. :)
>
> Without going too deep into the details of my app, I'm basically using my
> reduce function to reduce a set of timestamps to the most recent one, and
> then appending that value to another doc that I also pass in to the reduce
> function. This is probably tripping the reduce_limit guard because the
> result of the reduce is essentially the original document plus one extra
> property. The thing is, I know that it will only ever add one extra
> property, hence I know the reduce function is "good".
>
> My use case is that I've got a bunch of user documents and a bunch of
> timestamps of when we last saw that user. When I fetch the user doc, I'd
> like to also have present the timestamp when that user was last seen. I may
> just be greedy wanting to do this all in one query, but I'll be running
> this query very frequently so I'd like to optimize this case.
>
> --
> Michael Jackson
> @mjackson

Mime
View raw message