shardingsphere icon indicating copy to clipboard operation
shardingsphere copied to clipboard

Build performance of SingleRule needs to be optimized

Open RaigorJiang opened this issue 6 months ago • 0 comments

Which version of ShardingSphere did you use?

5.5.3-SNAPSHOT c1c77b20dabab3d87813262c3139dcba6535787c

Which project did you use? ShardingSphere-JDBC or ShardingSphere-Proxy?

ShardingSphere-Proxy

Expected behavior

When building a SingleRule, only load the table names from the data source included in the rule

For example, if ds_0 and ds_1 are registered in the logic database, but the single table rule only has - ds_0.t_single, there is no need to obtain the table names from ds_1

databaseName: sharding_db
dataSources:
  ds_0:
    password: 123456
    url: jdbc:mysql://127.0.0.1:3306/demo_ds_0?serverTimezone=Asia/Shanghai&characterEncoding=UTF-8&useSSL=false&allowPublicKeyRetrieval=true
    username: root
    minPoolSize: 1
    maxPoolSize: 10
  ds_1:
    password: 123456
    url: jdbc:mysql://127.0.0.1:3306/demo_ds_1?serverTimezone=Asia/Shanghai&characterEncoding=UTF-8&useSSL=false&allowPublicKeyRetrieval=true
    username: root
    minPoolSize: 1
    maxPoolSize: 10
rules:
- !SINGLE
  tables:
  - ds_0.t_single

Actual behavior

In the SingleTableDataNodeLoader#load method, the table names are first obtained from all data sources, and then compared with the tables in single rule, leaving the required parts, which wastes some time in loading table names from ds_1.

Image

RaigorJiang avatar Jun 11 '25 16:06 RaigorJiang