scylladb / java-driver

ScyllaDB Java Driver for ScyllaDB and Apache Cassandra, based on the DataStax Java Driver
Apache License 2.0
62 stars 37 forks source link

Suboptimal queries on Session/Connection initiation in version 4.17 #282

Open Foxlik opened 6 months ago

Foxlik commented 6 months ago

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.

mykaul commented 6 months ago

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)