java-driver icon indicating copy to clipboard operation
java-driver copied to clipboard

Suboptimal queries on Session/Connection initiation in version 4.17

Open Foxlik opened this issue 2 years ago • 1 comments

While looking into performance issues in one of our clusters I've noticed that the v4.17 Java driver does uses some sub-optimal queries on connecting to the cluster: https://github.com/scylladb/java-driver/blob/d33dbc598b3993e217d80cb14cd6c26119c46599/core/src/main/java/com/datastax/oss/driver/internal/core/channel/ProtocolInitHandler.java#L83 https://github.com/scylladb/java-driver/blob/d33dbc598b3993e217d80cb14cd6c26119c46599/core/src/main/java/com/datastax/oss/driver/internal/core/metadata/DefaultTopologyMonitor.java#L171 Both of these queries force full table scan as there's no key reference. I've tried appending WHERE key = 'local' to these queries and as a result the Session creation got about 90 % faster in the troubled cluster case. (YMMV)

This seems to be fixed in the 3.x version of the driver. https://github.com/scylladb/java-driver/blob/9fe1e03f1dc5380c517f5903cb1e78689566df96/driver-core/src/main/java/com/datastax/driver/core/ControlConnection.java#L79

Looks related to this issue.

Foxlik avatar Apr 12 '24 17:04 Foxlik

Seems to be the same as in upstream (https://github.com/apache/cassandra-java-driver/blob/388a46b9c10b5653c71ac8840bcda0c91b59bce4/core/src/main/java/com/datastax/oss/driver/internal/core/channel/ProtocolInitHandler.java#L72 for example)

mykaul avatar Apr 14 '24 06:04 mykaul