Sharding

    • Support query all data fragmentation rules and specified table query
    • Support query all sharding algorithms
    • Support query all sharding audit algorithms

    Sharding Table Reference Rule

    Broadcast Table Rule

    1. SHOW BROADCAST TABLE RULES [FROM databaseName]

    Sharding Table Rule

    Sharding Algorithms

    ColumnDescription
    nameSharding algorithm name
    typeSharding algorithm type
    propsSharding algorithm properties
    ColumnDescription
    nameSharding algorithm name
    typeSharding algorithm type
    propsSharding algorithm properties

    Sharding auditors

    Unused Sharding Auditors

    ColumnDescription
    nameSharding audit algorithm name
    typeSharding audit algorithm type
    propsSharding audit algorithm properties

    Sharding key generators

    ColumnDescription
    nameSharding key generator name
    typeSharding key generator type
    propsSharding key generator properties

    Unused Sharding Key Generators

    ColumnDescription
    nameStrategy name
    typeSharding strategy type
    sharding_columnSharding column
    sharding_algorithm_nameSharding algorithm name
    sharding_algorithm_typeSharding algorithm type
    sharding_algorithm_propsSharding algorithm properties

    Sharding Table Nodes

    ColumnDescription
    nameSharding rule name
    nodesSharding nodes

    Sharding Table Reference Rule

    Broadcast Table Rule

    ColumnDescription
    broadcast_tableBroadcast table

    Sharding Table Rule

    1. mysql> SHOW SHARDING TABLE RULES;
    2. +--------------+---------------------------------+-------------------+----------------------+------------------------+-------------------------------+----------------------------------------+-------------------+---------------------+----------------------------+---------------------------------------------------+-------------------+------------------+-------------------+
    3. | table | actual_data_nodes | actual_data_sources | database_strategy_type | database_sharding_column | database_sharding_algorithm_type | database_sharding_algorithm_props | table_strategy_type | table_sharding_column | table_sharding_algorithm_type | table_sharding_algorithm_props | key_generate_column | key_generator_type | key_generator_props |auditor_types | allow_hint_disable |
    4. +--------------+---------------------------------+-------------------+----------------------+------------------------+-------------------------------+----------------------------------------+-------------------+---------------------+----------------------------+---------------------------------------------------+-------------------+------------------+-------------------+
    5. | t_order | ds_${0..1}.t_order_${0..1} | | INLINE | user_id | INLINE | algorithm-expression:ds_${user_id % 2} | INLINE | order_id | INLINE | algorithm-expression:t_order_${order_id % 2} | order_id | SNOWFLAKE | |DML_SHARDING_CONDITIONS |true |
    6. | t_order_item | ds_${0..1}.t_order_item_${0..1} | | INLINE | user_id | INLINE | algorithm-expression:ds_${user_id % 2} | INLINE | order_id | INLINE | algorithm-expression:t_order_item_${order_id % 2} | order_item_id | SNOWFLAKE | | | |
    7. | t2 | | ds_0,ds_1 | | | | | mod | id | mod | sharding-count:10 | | | | | |
    8. +--------------+---------------------------------+-------------------+----------------------+------------------------+-------------------------------+----------------------------------------+-------------------+---------------------+----------------------------+---------------------------------------------------+-------------------+------------------+-------------------+
    9. 3 rows in set (0.02 sec)

    SHOW SHARDING TABLE RULE tableName

    1. mysql> SHOW SHARDING TABLE RULE t_order;
    2. +---------+----------------------------+-------------------+----------------------+------------------------+-------------------------------+----------------------------------------+-------------------+---------------------+----------------------------+----------------------------------------------+-------------------+------------------+-------------------+
    3. | table | actual_data_nodes | actual_data_sources | database_strategy_type | database_sharding_column | database_sharding_algorithm_type | database_sharding_algorithm_props | table_strategy_type | table_sharding_column | table_sharding_algorithm_type | table_sharding_algorithm_props | key_generate_column | key_generator_type | key_generator_props | auditor_types | allow_hint_disable |
    4. +---------+----------------------------+-------------------+----------------------+------------------------+-------------------------------+----------------------------------------+-------------------+---------------------+----------------------------+----------------------------------------------+-------------------+------------------+-------------------+
    5. | t_order | ds_${0..1}.t_order_${0..1} | | INLINE | user_id | INLINE | algorithm-expression:ds_${user_id % 2} | INLINE | order_id | INLINE | algorithm-expression:t_order_${order_id % 2} | order_id | SNOWFLAKE | | DML_SHARDING_CONDITIONS |true |
    6. +---------+----------------------------+-------------------+----------------------+------------------------+-------------------------------+----------------------------------------+-------------------+---------------------+----------------------------+----------------------------------------------+-------------------+------------------+-------------------+
    7. 1 row in set (0.01 sec)

    SHOW SHARDING ALGORITHMS

    1. mysql> SHOW SHARDING ALGORITHMS;
    2. | name | type | props |
    3. +-------------------------+--------+-----------------------------------------------------+
    4. | t_order_inline | INLINE | algorithm-expression=t_order_${order_id % 2} |
    5. | t_order_item_inline | INLINE | algorithm-expression=t_order_item_${order_id % 2} |
    6. +-------------------------+--------+-----------------------------------------------------+
    7. 2 row in set (0.01 sec)

    SHOW UNUSED SHARDING ALGORITHMS

    1. mysql> SHOW SHARDING AUDITORS;
    2. +------------+-------------------------+-------+
    3. | name | type | props |
    4. +------------+-------------------------+-------+
    5. | dml_audit | DML_SHARDING_CONDITIONS | |
    6. +------------+-------------------------+-------+
    7. 2 row in set (0.01 sec)

    SHOW SHARDING TABLE RULES USED ALGORITHM shardingAlgorithmName

    1. mysql> SHOW SHARDING TABLE RULES USED ALGORITHM t_order_inline;
    2. | type | name |
    3. +-------+---------+
    4. | table | t_order |
    5. +-------+---------+
    6. 1 row in set (0.01 sec)

    SHOW SHARDING KEY GENERATORS

    1. mysql> SHOW SHARDING KEY GENERATORS;
    2. +------------------------+-----------+-----------------+
    3. | name | type | props |
    4. +------------------------+-----------+-----------------+
    5. | t_order_snowflake | snowflake | |
    6. | t_order_item_snowflake | snowflake | |
    7. | uuid_key_generator | uuid | |
    8. +------------------------+-----------+-----------------+
    9. 3 row in set (0.01 sec)

    SHOW UNUSED SHARDING KEY GENERATORS

    1. mysql> SHOW UNUSED SHARDING KEY GENERATORS;
    2. +------------------------+-----------+-----------------+
    3. | name | type | props |
    4. +------------------------+-----------+-----------------+
    5. | uuid_key_generator | uuid | |
    6. +------------------------+-----------+-----------------+
    7. 1 row in set (0.01 sec)
    1. mysql> SHOW UNUSED SHARDING KEY AUDITORS;
    2. +------------+-------------------------+-------+
    3. | name | type | props |
    4. +------------+-------------------------+-------+
    5. +------------+-------------------------+-------+
    6. 1 row in set (0.01 sec)

    SHOW SHARDING TABLE RULES USED KEY GENERATOR keyGeneratorName

    SHOW SHARDING TABLE RULES USED AUDITOR auditorName

    1. mysql> SHOW SHARDING TABLE RULES USED AUDITOR sharding_key_required;
    2. +-------+---------+
    3. | type | name |
    4. +-------+---------+
    5. | table | t_order |
    6. 1 row in set (0.01 sec)

    SHOW DEFAULT SHARDING STRATEGY

    1. mysql> SHOW DEFAULT SHARDING STRATEGY ;
    2. +----------+---------+--------------------+-------------------------+-------------------------+------------------------------------------+
    3. | name | type | sharding_column | sharding_algorithm_name | sharding_algorithm_type | sharding_algorithm_props |
    4. +----------+---------+--------------------+-------------------------+-------------------------+------------------------------------------+
    5. | TABLE | NONE | | | | |
    6. | DATABASE | STANDARD| order_id | database_inline | INLINE | {algorithm-expression=ds_${user_id % 2}} |
    7. +----------+---------+--------------------+-------------------------+-------------------------+------------------------------------------+
    8. 2 rows in set (0.07 sec)
    1. mysql> SHOW SHARDING TABLE NODES;
    2. +---------+----------------------------------------------------------------+
    3. | name | nodes |
    4. +---------+----------------------------------------------------------------+
    5. | t_order | ds_0.t_order_0, ds_1.t_order_1, ds_0.t_order_2, ds_1.t_order_3 |
    6. +---------+----------------------------------------------------------------+
    7. 1 row in set (0.02 sec)
    1. mysql> SHOW SHARDING TABLE REFERENCE RULES;
    2. +-------+--------------------------+
    3. | name | sharding_table_reference |
    4. +-------+--------------------------+
    5. | ref_0 | t_a,t_b |
    6. | ref_1 | t_c,t_d |
    7. +-------+--------------------------+
    8. 2 rows in set (0.00 sec)

    Broadcast Table Rule

    1. mysql> SHOW BROADCAST TABLE RULES;
    2. +-----------------------+
    3. | broadcast_table |
    4. +-----------------------+
    5. | t_1 |
    6. | t_2 |
    7. +-----------------------+