Hi!
I'm using Cassandra Java Driver 4.2.0 to perform multiple asynchronous SELECT queries with the following code:
for (int i = 1; i <= 20; i++) { String currentKey = "key_"+i; SimpleStatement stmt = SimpleStatement.newInstance("SELECT * FROM mykeyspace.table1 WHERE "+ "my_key='"+currentKey+"'") .setTimeout(Duration.ofMillis(5000)).setConsistencyLevel(ConsistencyLevel.ONE).setPageSize(10000); long start = System.nanoTime(); CompletableFuture<?> f = session.executeAsync(stmt).toCompletableFuture(); f.thenRunAsync(() -> logger.info(currentKey+" SELECT duration: "+(System.nanoTime()-start))); }
my_key column is the partition key for table1, the result of each query consists of 10000-20000 rows.
As I see in the output (the result of last line of code above), the duration of query execution grows, i.e. query results are obtained not in parallel: while result of 1st query is being transferred to my machine, result of 2nd query is not transferred.
My assumption this is because of single network connection to Cassandra being used. If my assumption is correct, is there a way to utilize multiple network connections to perform queries and obtain results in parallel? Does the java Driver provide such an option?