I am executing same query in parallel in 11 threads and I am getting huge difference in execution time of these queries. And if I execute only one query it executes very fast.
Thread code: I used 11 threads
Thread t1 = new Thread(new Runnable() {
public void run() {
try {
QueryResult result= null;
double qstart = System.currentTimeMillis();
ClusterEnvironment env = ClusterEnvironment
.builder()
.timeoutConfig(TimeoutConfig.kvTimeout(Duration.ofMinutes(15)))
.build();
Cluster cluster = Cluster.connect("xx.xx.xx.xxx", "**********", "************");
Bucket bucket = cluster.bucket("case5");
Collection collection = bucket.defaultCollection();
double qend1 = System.currentTimeMillis();
result = cluster.query("select `user`.userID,`user`.userName,`user`.employeeCode,`user`.personalDetails.userEmail[0].emailAddress,`user`.userDateOfBirth,`user`.userAddress from case3 where `user`.userID=\"user1\" and document.documentType=\"01\" and document.featureID=\"101\" and document.tenantID=\"CUST1\"",QueryOptions.queryOptions().metrics(true));
double qend = System.currentTimeMillis();
System.out.println("1Reported execution time: "
+ result.metaData().metrics());
System.out.println("1metaData"+result.metaData());
double qout = qend - qend1;
System.out.println("1"+cluster.diagnostics());
System.out.println("1Query time = " + qout);
for (JsonObject row : result.rowsAsObject()) {
System.out.println("1Found row: " + row);
}cluster.disconnect();
}
catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
}
}});
Output:
200
messageOK
{"message":"success","data":["query execution time : 677.0.....]}
200
messageOK
{"message":"success","data":["query execution time : 19.0.....]}
200
messageOK
{"message":"success","data":["query execution time : 18.0.....]}
200
messageOK
{"message":"success","data":["query execution time : 18.0.....]}
200
messageOK
{"message":"success","data":["query execution time : 129.0.....]}
200
messageOK
{"message":"success","data":["query execution time : 39.0.....]}
200
messageOK
{"message":"success","data":["query execution time : 17.0.....]}
200
messageOK
{"message":"success","data":["query execution time : 197.0.....]}
200
messageOK
{"message":"success","data":["query execution time : 41.0.....]}
200
messageOK
{"message":"success","data":["query execution time : 20.0.....]}
200
messageOK
{"message":"success","data":["query execution time : 13.0.....]}
And for single execution its taking only 5ms. Is their any settings to do before executing parallel queries, why their is so much variation?? Please help me out!