MySQL中DBLE 分区算法系列总结-爱可生



DBLE 与 MyCat 对应分片算法名和异同

MySQL中DBLE 分区算法系列总结-爱可生


第七种 DBLE分片算法—jumpStringHash

除了以上六种常见的分片算法之外,DBLE 还独有一种分片算法:跳跃字符串算法。

具体配置如下:

<code>#rule.xml<function>        <property>2/<property>        <property>0:2/<property>/<function>/<code>

partitionCont:分片数量

hashSlice:分片截取长度

该算法来自于 Google 的一篇文章《A Fast, Minimal Memory, Consistent Hash Algorithm》其核心思想是通过概率分布的方法将一个hash值在每个节点分布的概率变成1/n,并且可以通过更简便的方法可以计算得出,而且分布也更加均匀。

注意事项:分片字段值为NULL时,数据恒落在0号节点之上;当真实存在于mysql的字段值为not null的时候,报错 "Sharding column can't be null when the table in MySQL column is not null"

至此,我们DBLE中支持的七种分片算法就介绍完了,相信读者朋友对 DBLE 的使用也慢慢熟悉。

系列文章的最后:

完整分区实例

<code><rule>    <tablerule>        <rule>            <columns>id/<columns>            <algorithm>enum/<algorithm>        /<rule>    /<tablerule>    <tablerule>        <rule>            <columns>id/<columns>            <algorithm>rangeLong/<algorithm>        /<rule>    /<tablerule>    <tablerule>        <rule>            <columns>id/<columns>            <algorithm>hashLong/<algorithm>        /<rule>    /<tablerule>    <tablerule>        <rule>            <columns>id/<columns>            <algorithm>hashLong2/<algorithm>        /<rule>    /<tablerule>    <tablerule>        <rule>            <columns>id/<columns>            <algorithm>hashLong3/<algorithm>        /<rule>    /<tablerule>    <tablerule>        <rule>            <columns>id/<columns>            <algorithm>hashmod/<algorithm>        /<rule>    /<tablerule>    <tablerule>        <rule>            <columns>id/<columns>            <algorithm>hashString/<algorithm>        /<rule>    /<tablerule>    <tablerule>        <rule>            <columns>calldate/<columns>            <algorithm>partbydate/<algorithm>        /<rule>    /<tablerule>    <tablerule>        <rule>            <columns>id/<columns>            <algorithm>pattern/<algorithm>        /<rule>    /<tablerule>        <function>        <property>partition-hash-int.txt/<property>        <property>0/<property>        <property>0/<property>    /<function>        <function>        <property>autopartition-long.txt/<property>        <property>0/<property>    /<function>            <function>        <property>8/<property>        <property>128/<property>            /<function>            <function>        <property>2/<property>        <property>512/<property>            /<function>            <function>        <property>2,1/<property>        <property>256,512/<property>            /<function>        <function>        <property>4/<property>        <property>1/<property>    /<function>        <function>        <property>8/<property>        <property>128/<property>        <property>0:2/<property>            /<function>            <function>        <property>yyyy-MM-dd/<property>        <property>2015-01-01/<property>        <property>2015-01-31        /<property>         <property>10/<property>        <property>0/<property>    /<function>            <function>        <property>partition-pattern.txt/<property>        <property>1024/<property>        <property>0/<property>    /<function>/<rule>/<code>

左右滑动进行查看

MySQL中DBLE 分区算法系列总结-爱可生


分享到:


相關文章: