MapReduce-View performance very slow


#1

I have just about 3K json documents in bucket and each document size is about 1KB only.
Following are CB and machine details.
Couchbase - 4.0.0-4047 Enterprise Edition (Single server)
Total allocated RAM - 600MB
InUse - 254MB

Bucket
RAM/Quota - 37.3MB/100MB
Data/DiskUsage - 35MB/40MB

Windows 7 64 bit , 4core AMD processor.

Using Java SDK client version 2.2.1

Querying against view takes approx 180millisec. I think this is still high considering very few documents are present in bucket. Using Stale=False and it’s development view.

If i run parallel requests to view the response time degrades a lot.
5 parallel calls = avg response time is ~230 millisec
10 parallel calls = avg response time is ~450 millisec

Please suggest if i need to modify any settings. Also is there any url/doc etc which discusses performance tuning as whole.
No documents are getting updated/created/deleted when I’m requesting view.

I tried using N1QL too but it was much worse than view when parallel queries are made. I did create covering index.


#2

Can you share with us the view code and a sample document?

What happens if you run the query with stale=true?

Are you able to allocate more disk space to the bucket?


#3

here’s view

function (doc, meta) {
  var currDate = new Date();
  currDate.setHours(0,0,0,0);
  if(doc.feeId){
    if(doc.expirationDate == null || (new Date(doc.expirationDate)) >= currDate){
                  emit(doc.propertyCode, meta.id);   
     }
  }
}

I dont see much improvement by using stale=true. Following is java code snippet

ViewResult result = testBucket.query(ViewQuery.from("tax_fees", "by_taxes").development(true).stale(Stale.TRUE).key("PHXME"));

How to allocate more disk space . Can i do it without re-creating the bucket ? Don’t see any option for it when i ‘edit’ the bucket. I just see RAM allocation only.


#4

Unrelated to your performance issue, but you shouldn’t use Dates in your map function. Your map function should be pure - i.e. it should always give the same output regardless of when it is run, given a specific input.

If you want to perform operations with dates, you probably want to emit() a date, and then perform the comparison as part of your query.

The reason for this is that the map() function can be applied to documents at different times - i.e. the view could be regenerated (and map function run) when you haven’t modified your document, for example during rebalance.


#5

Thank you @drigby for pointing out bug in my view.