You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@shardingsphere.apache.org by 梁维伟 <15...@163.com> on 2019/10/31 09:17:26 UTC

About key generated by built-in snowflake algorithm(Sharding-JDBC)

Hi.
I found that the result of (the key mod 4) always is 0/1, to me, it is wierd. What I expected is, the result should be 0/1/2/3, and the key should evenly distributed to all the sharded tables. I am new to ShardingSphere and the snowflake algorithm. Hope I can get some help from you. 

Thanks.

Re: About key generated by built-in snowflake algorithm(Sharding-JDBC)

Posted by Juan Pan <pa...@apache.org>.
Here is the introduction of snowflake[1].


[1] https://shardingsphere.apache.org/document/current/en/features/sharding/other-features/key-generator/


 Juan Pan


panjuan@apache.org
Juan Pan(Trista), Apache ShardingSphere
On 10/31/2019 17:17, 梁维伟 wrote:
Hi.
I found that the result of (the key mod 4) always is 0/1, to me, it is wierd. What I expected is, the result should be 0/1/2/3, and the key should evenly distributed to all the sharded tables. I am new to ShardingSphere and the snowflake algorithm. Hope I can get some help from you.

Thanks.

Re: About key generated by built-in snowflake algorithm(Sharding-JDBC)

Posted by "zhangliang@apache.org" <zh...@apache.org>.
What's your version of ShardingSphere and what is you configuration?

------------------

Liang Zhang (John)
Apache ShardingSphere & Dubbo


梁维伟 <15...@163.com> 于2019年10月31日周四 下午8:36写道:

> Hi.
> I found that the result of (the key mod 4) always is 0/1, to me, it is
> wierd. What I expected is, the result should be 0/1/2/3, and the key should
> evenly distributed to all the sharded tables. I am new to ShardingSphere
> and the snowflake algorithm. Hope I can get some help from you.
>
> Thanks.