Hi,
We are migrating to use couchbase for storage and i was doing some tests to mesure the performance.
We have installed server 4.6 and I’m using the java client 2.4.3.
The query I’m using is the following:
SELECT T., Product., Account.* FROM MyBucket T
JOIN MyBucket Product ON KEYS T.product_ref
JOIN MyBucket Account ON KEYS T.account_ref
where T.type=‘Transaction’ and Product.type = ‘Product’ and Account._type=‘Account’
I have indexed the field _type and my bucket contains 300 000 documents.
I’m using the following code for test:
N1qlQuery query = N1qlQuery.simple(queryString);
final AtomicInteger count=new AtomicInteger(0);
CountDownLatch countDownLatch=new CountDownLatch(1);
bucket.async().query(query)
.timeout(60000, TimeUnit.SECONDS) //global timeout for the query
//.flatMap(asyncN1qlQueryResult → asyncN1qlQueryResult.rows()) // //browse the resulting rows
.flatMap(asyncN1qlQueryResult ->asyncN1qlQueryResult.errors()
.flatMap(error →
Observable.error(
new RuntimeException("Error while performing query: "
+ error)))
.switchIfEmpty(asyncN1qlQueryResult.rows()))
.map(asyncN1qlQueryRow → asyncN1qlQueryRow.value()) ////extract the value of rows that were obtained
.subscribe(new Subscriber() {
@Override
public void onCompleted() {
System.out.println(“complete”);
countDownLatch.countDown();
}
@Override
public void onError(Throwable e) {
System.out.println(“Error…”);
e.printStackTrace();
countDownLatch.countDown();
//throw new RuntimeException(e);} @Override public void onNext(JsonObject t) { //System.out.println("next.."+t); count.incrementAndGet(); } }); try { countDownLatch.await(); System.out.println("Finished in "+((System.currentTimeMillis()-start)/1000)); System.out.println("Found "+count.intValue()); } catch (InterruptedException e1) { e1.printStackTrace(); }
When testing on my local couchbase server, the query finishes in 37 seconds which is high!
But, when testing the same code on a remote couhbase server,I’m surprised about the result:
java.lang.RuntimeException: Error while performing query: {“msg”:“Timeout 1h0m0s exceeded”,“code”:4080}
Finished in 3620
Found 0
at …
at rx.internal.operators.OnSubscribeMap$MapSubscriber.onNext(OnSubscribeMap.java:69)
at rx.internal.operators.OnSubscribeMap$MapSubscriber.onNext(OnSubscribeMap.java:77)
at rx.internal.operators.OperatorObserveOn$ObserveOnSubscriber.call(OperatorObserveOn.java:224)
at rx.internal.schedulers.ScheduledAction.run(ScheduledAction.java:55)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
The query didnn’t finish even after 1 houre (I have set 1 hour as a query timeout when building my CouchbaseEnvironment.
Any help please about this results?