TeslaCN opened a new issue #12032: URL: https://github.com/apache/shardingsphere/issues/12032
## Feature Request ### Is your feature request related to a problem? The performance loss of readwrite-splitting in ShardingSphere 5 is larger than ShardingSphere 4. #### Sharding JDBC 4.1.1 The performance of MasterSlave in Sharding-JDBC 4.1.1 is very close to native JDBC, because routed prepared statements are cached in `MasterSlavePreparedStatement` and each invoking `executeQuery` is invoking the native PreparedStatement. https://github.com/apache/shardingsphere/blob/96375f420074a8a4cba5307f1a308f3a87b3c7bf/sharding-jdbc/sharding-jdbc-core/src/main/java/org/apache/shardingsphere/shardingjdbc/jdbc/core/statement/MasterSlavePreparedStatement.java#L42-L47 https://github.com/apache/shardingsphere/blob/96375f420074a8a4cba5307f1a308f3a87b3c7bf/sharding-jdbc/sharding-jdbc-core/src/main/java/org/apache/shardingsphere/shardingjdbc/jdbc/core/statement/MasterSlavePreparedStatement.java#L118-L122 Flame graph of Sharding-JDBC 4.1.1  #### ShardingSphere JDBC 5.0.0 (master) There is no `MasterSlavePreparedStatement` or `ReadWriteSplittingPreparedStatement` in ShardingSphere 5.0.0. `ShardingSpherePreparedStatement` can be used for different functions. But the statements are not reused. Every time execute the PreparedStatement, `clearPrevious` will close all statements opened by the previous execution. And then create new PreparedStatements in prepare engine. This may be expensive, especially `useServerPrepStmts` is enabled and cache size is not large enough in MySQL JDBC driver. https://github.com/apache/shardingsphere/blob/ca07e82161d9448b7e3485d6e35b0d316ba6b9c2/shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/org/apache/shardingsphere/driver/jdbc/core/statement/ShardingSpherePreparedStatement.java#L174 https://github.com/apache/shardingsphere/blob/ca07e82161d9448b7e3485d6e35b0d316ba6b9c2/shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/org/apache/shardingsphere/driver/jdbc/core/statement/ShardingSpherePreparedStatement.java#L400-L403 Flame graph of ShardingSphere JDBC 5.0.0 (master)  ### Describe the feature you would like. Consider caching prepared statements for reuse if the rules only contains ReadWriteSplitting. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
