Logo
Data Sharding

Data Sharding #

Configuration Entry #

Class name: org.apache.shardingsphere.sharding.api.config.ShardingRuleConfiguration

configurable properties:

NameData typeDescriptionDefault value
tables (+)Collection<ShardingTableRuleConfiguration>List of sharding table rules-
autoTables (+)Collection<ShardingAutoTableRuleConfiguration>List of auto sharding table rules-
bindingTableGroups (*)Collection<String>List of binding table rulesNone
broadcastTables (*)Collection<String>List of broadcast table rulesNone
defaultDatabaseShardingStrategy (?)ShardingStrategyConfigurationDefault sharding database strategyNone sharding
defaultTableShardingStrategy (?)ShardingStrategyConfigurationDefault sharding table strategyNone sharding
defaultKeyGenerateStrategy (?)KeyGeneratorConfigurationDefault key generator configurationSnowflake algorithm
defaultShardingColumn (?)StringDefault sharding column nameNone
shardingAlgorithms (+)Map<String, ShardingSphereAlgorithmConfiguration>Sharding algorithm name and configurationNone
keyGenerators (?)Map<String, ShardingSphereAlgorithmConfiguration>Key generator name and configurationNone

Sharding Table Configuration #

Class name: org.apache.shardingsphere.sharding.api.config.ShardingTableRuleConfiguration

configurable properties:

NameData typeDescriptionDefault value
logicTableStringLogical sharding table name-
actualDataNodes (?)StringIt consists of data source name + table name, separated by decimal points.
Multiple tables are separated by commas, and row value expressions are supported
Use known data sources and logical table names to generate data nodes, which are used for broadcast tables or when only sharding databases are not sharding tables and the table structures of all databases are exactly the same
databaseShardingStrategy (?)ShardingStrategyConfigurationSharding database strategyUsing default sharding database strategy
tableShardingStrategy (?)ShardingStrategyConfigurationSharding table strategyUsing default sharding table strategy
keyGenerateStrategy (?)KeyGeneratorConfigurationKey generatorUsing default key generator

Auto Sharding Table Configuration #

Class name:org.apache.shardingsphere.sharding.api.config.ShardingAutoTableRuleConfiguration

configurable properties:

NameData typeDescriptionDefault value
logicTableStringLogical sharding table name-
actualDataSources (?)StringData source name, multiple data sources separated by commasUse all configured data sources
shardingStrategy (?)ShardingStrategyConfigurationSharding strategyUsing default sharding strategy
keyGenerateStrategy (?)KeyGeneratorConfigurationKey generatorUsing default key generator

Sharding Strategy Configuration #

Standard Sharding Strategy Configuration #

Class name: org.apache.shardingsphere.sharding.api.config.strategy.sharding.StandardShardingStrategyConfiguration

configurable properties:

NameData typeDescription
shardingColumnStringSharding column name
shardingAlgorithmNameStringSharding algorithm name

Complex Sharding Strategy Configuration #

Class name: org.apache.shardingsphere.sharding.api.config.strategy.sharding.ComplexShardingStrategyConfiguration

configurable properties:

NameData typeDescription
shardingColumnsStringSharding column name, multiple columns separated by commas
shardingAlgorithmNameStringSharding algorithm name

Hint Sharding Strategy Configuration #

Class name: org.apache.shardingsphere.sharding.api.config.strategy.sharding.HintShardingStrategyConfiguration

configurable properties:

NameData typeDescription
shardingAlgorithmNameStringSharding algorithm name

None Sharding Strategy Configuration #

Class name: org.apache.shardingsphere.sharding.api.config.strategy.sharding.NoneShardingStrategyConfiguration

configurable properties: None

For details of sharding algorithm types, please refer to Built-in sharding algorithms list

Distributed Key Generate Strategy Configuration #

Class name: org.apache.shardingsphere.sharding.api.config.strategy.keygen.KeyGenerateStrategyConfiguration

configurable properties:

NameData typeDescription
columnStringDistributed key generate column name
keyGeneratorNameStringDistributed key generate algorithm name

For details of key generator algorithm types, please refer to Built-in key generator algorithm list