Java driver gives me a value of 423 millisecond whereas in CQL it takes 3.2millisecond for the same insert query. Why is CQL faster that running through Java
Bringing together the Apache Cassandra experts from the community and DataStax.
Want to learn? Have a question? Want to share your expertise? You are in the right place!
Not sure where to begin? Getting Started
Java driver gives me a value of 423 millisecond whereas in CQL it takes 3.2millisecond for the same insert query. Why is CQL faster that running through Java
I'm assuming you meant "cqlsh" instead of "CQL". If so, it is not an apples-for-apples comparison.
When you run cqlsh on a node, you are directly connected to the cluster and there is no network hop between the client (cqlsh) and the database. When you run queries using your app, you have to account for the fact that there is at least one network hop (possibly more) required to send the query to the cluster.
In addition to the network hop, using cqlsh locally uses the node as the coordinator for the request and by default uses a consistency of ONE
unless you override it. When your app sends a request through the driver, the driver must first generate a query plan (a list of nodes to contact and use as a coordinator), connect to a contact point, then send the request.
And if you look under the hood, it gets a bit more complicate because there are things like address resolution required, synchronous vs asynchronous requests, etc. In any case, it's not a fair comparison since running queries locally directly on a node in the cluster will always be faster. Cheers!
7 People are following this question.
DataStax Enterprise is powered by the best distribution of Apache Cassandra ™
© 2022 DataStax, Titan, and TitanDB are registered trademarks of DataStax, Inc. and its subsidiaries in the United States and/or other countries.
Apache, Apache Cassandra, Cassandra, Apache Tomcat, Tomcat, Apache Lucene, Lucene, Apache Solr, Apache Hadoop, Hadoop, Apache Spark, Spark, Apache TinkerPop, TinkerPop, Apache Kafka and Kafka are either registered trademarks or trademarks of the Apache Software Foundation or its subsidiaries in Canada, the United States and/or other countries.
Privacy Policy Terms of Use