Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <ol> <li><p>There are no global variables inside a function. It has only local variables. Global variables only could be defined in global scope (outside of function). But in couchbase you can't define any variables outside of reduce function.</p></li> <li><p>If you want to measure view performance your code is complitly wrong, because you'll just measure a part of it, because this function can be called multiple times. Read couchbase docs about reduce function (see links below).</p></li> <li><p>At last, the code you've written will not measure view performance, because it can only measure view indexing performance. And view performance is not equal to indexing performance, basically because indexing process in most cases runs in background, and it not affects view performance.</p></li> </ol> <p>I recommend you to read this <a href="http://docs.couchbase.com/couchbase-manual-2.0/#views-and-indexes" rel="nofollow">document</a> about views and how do they work. Also pay attention to <a href="http://docs.couchbase.com/couchbase-manual-2.0/#handling-rereduce" rel="nofollow">paragraph</a> about reduce functions.</p> <p>UPD: Global variables couldn't exist in context of reduce function. If you carefully read documentation about view and it's reduce function, you should understand that reduce function can be called multiple times on different servers in cluster. So you can't define any variable that will be global on multiple servers in cluster. You can only operate with variables that you return. Also you need to handle <code>rereduce</code> in your reduce function, if you don't, you'll count time of lastest reduce's rereduce and ignore all previous values.</p> <p>Better way to measure view's performance is to genereate loadtest and operate with maximum operations/second, not absolute time of view indexing process. If you need to meaasure indexing speed - query your view with <code>stale=false</code> param that will force couchbase to update index before returning result, so time of that query will represent time taken for mapping and reducing your result (i.e. you can even use curl or web browser). But in real application you need to avoid queries with <code>stale=false</code>.</p> <p>To tune your reduce code, you can just measure it performance in browser, or better in nodejs. Just copy your reduce function and call it with your map data. If you optimize your code in browser, your code will be faster in CB. You can even find online jsvascript map-reduce emulators.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload