Couchbase Version: 4.5.0-2601 Enterprise Edition (build-2601)
couchbase-client-version: 2.3.5
Java code: Using prepare statement with positional parameters to form the search query.
final N1qlParams params = N1qlParams.build().consistency(ScanConsistency.REQUEST_PLUS);
final ParameterizedN1qlQuery query = ParameterizedN1qlQuery.parameterized(statement.toString(), values, params); (statement -> below is the statement formed, values -> set by JsonArray)
final N1qlQueryResult queryResult = Constants.CUSTOMER_BUCKET.query(query);
{“args”:[“userprofile::%”,“shaik%”],“statement”:“SELECT meta().id, lastName, firstName, birthday, emails, phones, addresses[0] AS address FROM cpm-prosodie
WHERE meta().id LIKE $1 AND lower(lastName) LIKE $2 ORDER BY lastName LIMIT 20 OFFSET 0”,“scan_consistency”:“request_plus”}
executionTime=‘28.215477072s’ (which is obviously not considerable as a REST API service response)
**Whereas the same above query when hard-coded in java / run through CB query window: **
{“statement”:“SELECT meta().id, lastName, firstName, birthday, emails, phones, addresses[0] AS address FROM cpm-prosodie
WHERE meta().id LIKE ‘userprofile::%’ AND lower(lastName) LIKE ‘shaik%’ ORDER BY lastName LIMIT 20 OFFSET 0”}
** executionTime=‘12.839962ms’** (GOOD TIME RESULT)
Index on lastName: Global secondary index
CREATE INDEX lastName_lower
ON cpm-prosodie
(lower(lastName
)) USING GSI
WITH {“nodes”:[“10.64.201.4:8091”]}; (one node from CB cluster(contains 3 nodes, currently using only this node))
Primary Index:
CREATE PRIMARY INDEX #primary1
ON cpm-prosodie
Can anyone please guide what is going wrong in this…
Kuddos