表切分规则
<?xml version="1.0" encoding="UTF-8"?>
<!DOCYPE mycat:rule SYSEM "rule.dtd">
<mycat:rule xmlns:mycat="http://org.opencloudb/">
<tableRule name="sharding-by-hour">
<rule>
<consumer>createTime</consumer>
<algorithm>sharding-by-hour</algorithm>
</rule>
</tableRule>
<function name="sharding-by-hour" class="org.opencloudb.route.function.LatestMonthPartion">
<property name="splitOneDay">24</property>
</function>
</mycat:rule>
数据切分中作为表切分规则中最重要的配置,表的切分方式决定了数据切分后的性能好坏,因此也是最重要的配置。如上面例子配置了一个切分规则,名为sharding-by-hour对应的切分方式(function)是按日期切分,该配置中:
tableRule
name 为schema.xml中table标签中对应的rule=“sharding-by-hour”,也就是配置表的分片规则,colums是表的切分字段:createTime创建日期。
algorithm是规则对应的切分规则:映射到function的name。
function
function 配置是分片规则的配置。
name 为切分规则的名称,名字任意取,需要哪种规则则配置哪种,例如本例是按小时分片:
org.opencloudb.route.function.LatesMonthPartion.
property标签是切分规则对应的不同属性,不同的切分规则配置不同。