Key Generate Algorithm

    After data sharding, it is a very tricky problem to generate global unique primary keys from different data nodes. Self-incrementing keys between different actual tables within the same logical table generate duplicate primary keys because they are not mutually perceived.

    Although collisions can be avoided by constraining the initial value and step size of self-incrementing primary keys, additional O&M rules must to be introduced, making the solution lack completeness and scalability.

    There are many third-party solutions that can perfectly solve this problem, such as UUID, which relies on specific algorithms to generate non-duplicate keys, or by introducing primary key generation services.

    In order to cater to the requirements of different users in different scenarios, Apache ShardingSphere not only provides built-in distributed primary key generators, such as UUID, SNOWFLAKE, but also abstracts the interface of distributed primary key generators to facilitate users to implement their own customized primary key generators.

    Attributes:

    Note: worker-id is optional

    1. In cluster mode, it will be automatically generated by the system, and duplicate values will not be generated in the same namespace.

    Type:NANOID

    Configurable Property:none

    Attributes: None

    Type: COSID

    Attributes:

    Type: COSID_SNOWFLAKE

    1. Policy of distributed primary key configurations is for columns when configuring data sharding rules.
    • Snowflake Algorithms
    • NanoID