1

I’ve got quite a large dataset in Couchbase and observing slowness in the query when I get the meta().id from one of the CB document and then retrieve the actual document based on meta().id using the below implementation (Java SDK 2.7.6) -

is there any way to parallelize or could you please suggest any improvement

        List<Map<String, Object>> response = bucket.async().query(N1qlQuery.simple(query))
                .flatMap(result -> result.rows()).map(row -> row.value().toMap())
                .map(object -> (String) object.get("id"))
                .flatMap(id -> bucket.async().get(id))
                .map(d -> d.content().toMap())
                .toList()
                .toBlocking().single()
Matthew Groves
  • 25,181
  • 9
  • 71
  • 121
Developer
  • 239
  • 1
  • 3
  • 17
  • If you know the index that this query is using, please add it to your question. Also, the version of Couchbase Server you're using. – Matthew Groves Jun 21 '21 at 13:22
  • I'd also like to know why you think it is the query that is slow. I don't know how many documents you are fetching in that last `flatmap` but it might be quite a few... – G. Blake Meike Jun 22 '21 at 16:40
  • Sometimes we have to wait for more than 2 minutes to get the documents. It seems that rx.observables.BlockingObservable:single:340###rxrx.observables.BlockingObservable:blockForSingle:460###rx.internal.util.BlockingUtils:awaitForComplete:47###java.util.concurrent.locks.LockSupport:park:186 is taking lot of time – Developer Jun 22 '21 at 20:06

0 Answers0