On Tue, Mar 10, 2009 at 9:18 PM, kowsik <[email protected]> wrote:
> And the source code as defined in the view is parsed and executed
> __each__ time reduce is called on the changed docs. I think the intent
> was that the view server has no clue when _design views actually
> change. So couchdb passes in the actual string corresponding to the
> view function each time it wants couchjs to reduce a bunch of
> key/values. I suppose you could precompile these functions in the view
> server and have it return "handles" to couchdb that can be used at a
> later stage.
>

For future reference, map functions are compiled once per view update.
Reduce functions are compiled multiple times.

As jchris says, there's definitely room for improvement.

> But, I don't think anyone has benchmarked the view server to see where
> it's spending the most amount of time to implement these
> optimizations.
>
> K.
>
> On Tue, Mar 10, 2009 at 5:10 PM, Jens Alfke <[email protected]> wrote:
>>
>> On Mar 9, 2009, at 5:31 PM, Adam Wolff wrote:
>>
>>> but it bothers me a little that those three functions are defined every
>>> time
>>> that reduce is run.
>>
>> They're not. They're defined when the source code is parsed, not when it's
>> run. The only difference it makes to have them inside the reduce function is
>> that they can access local variables of that function. There shouldn't be
>> any difference in speed.
>>
>> —Jens
>

Reply via email to