Mycat(proxy中間件層)mysql
Sharding-jdbc(TDDL爲表明的應用層)sql
1.全局表 工具
2.Share Join性能
mysql> /*!mycat:catlet=io.mycat.catlets.ShareJoin*/select * from employee a, employee_detail b where a.id = b.id;spa
目前只支持兩張分片表的Join。3d
3.ER表code
<table name="customer" primaryKey="ID" dataNode="dn1,dn2" rule="sharding-by-intfile"> <childTable name="orders" primaryKey="ID" joinKey="customer_id" parentKey="id"> <childTable name="order_items" joinKey="order_id" parentKey="id" /> </childTable> <childTable name="customer_addr" primaryKey="ID" joinKey="customer_id" parentKey="id" /> </table>
childTable標籤用來聲明子表:xml
joinKey:聲明子表的那個字段和主表關聯中間件
parentKey:聲明主表的關聯主鍵blog
primaryKey:主表自身的主鍵
分頁的大坑必定要注意:
mysql> select * from customer order by id limit 1000000,100;
Mycat會分紅:
1 -> dn1{SELECT * FROM customer ORDER BY id LIMIT 0, 1000100}
2 -> dn2{SELECT * FROM customer ORDER BY id LIMIT 0, 1000100}
開啓使用非堆內存。減小內容消耗
<property name="useOffHeapForMerge">1</property>
MyCat註解規範
建立存儲過程:
/*!mycat:sql=select 1 from customer*/create producer ‘test_proc()’ BEGIN END;
調用存儲過程:
/*!mycat:sql=select 1 from customer*/call ‘test_proc()’;
Mycat管理端使用
Zookeeper工具:ZooInspector