1.使用expression完美支持分片替换问题
2.支持insert批量以及select in的分片替换,以及支持嵌套问题
mysql> explain insert into test
(id,name) values (1,'brucexx'),('2','brucexx');
No connection. Trying to reconnect...
Connection id: 1
Current database: *** NONE ***
+------------+----------------------------------------------------------+
| DATA_NODE | SQL |
+------------+----------------------------------------------------------+
| local_node | INSERT INTO test_01
(id, name) VALUES (1, 'brucexx') |
| local_node | INSERT INTO test_02
(id, name) VALUES ('2', 'brucexx') |
+------------+----------------------------------------------------------+
2 rows in set (0.31 sec)
mysql> explain select * from test where id in ('1',2,3,4,5,6);
+------------+----------------------------------------------+
| DATA_NODE | SQL |
+------------+----------------------------------------------+
| local_node | SELECT * FROM test_00
WHERE id IN (4) |
| local_node | SELECT * FROM test_01
WHERE id IN ('1', 5) |
| local_node | SELECT * FROM test_02
WHERE id IN (2, 6) |
| local_node | SELECT * FROM test_03
WHERE id IN (3) |
+------------+----------------------------------------------+
4 rows in set (0.08 sec)
mysql> explain select * from (select * from test union select * from test where id =1) as t where t.id in ('1',2,3,4,5,6);
+------------+--------------------------------------------------------------------------------------------------------------------+
| DATA_NODE | SQL |
+------------+--------------------------------------------------------------------------------------------------------------------+
| local_node | SELECT * FROM ((SELECT * FROM test_00
) UNION (SELECT * FROM test_00
WHERE id = 1)) AS T WHERE t.id IN (4) |
| local_node | SELECT * FROM ((SELECT * FROM test_01
) UNION (SELECT * FROM test_01
WHERE id = 1)) AS T WHERE t.id IN ('1', 5) |
| local_node | SELECT * FROM ((SELECT * FROM test_02
) UNION (SELECT * FROM test_02
WHERE id = 1)) AS T WHERE t.id IN (2, 6) |
| local_node | SELECT * FROM ((SELECT * FROM test_03
) UNION (SELECT * FROM test_03
WHERE id = 1)) AS T WHERE t.id IN (3) |
+------------+--------------------------------------------------------------------------------------------------------------------+
4 rows in set (0.02 sec)
mysql> explain select t.name from (select * from test ) as t left join test on t.id=test.id where t.id in ('1',2,3,4,5,6);
+------------+----------------------------------------------------------------------------------------------------------------+
| DATA_NODE | SQL |
+------------+----------------------------------------------------------------------------------------------------------------+
| local_node | SELECT t.name FROM (SELECT * FROM test_00
) AS T LEFT JOIN test_00
ON t.id = test.id WHERE t.id IN (4) |
| local_node | SELECT t.name FROM (SELECT * FROM test_01
) AS T LEFT JOIN test_01
ON t.id = test.id WHERE t.id IN ('1', 5) |
| local_node | SELECT t.name FROM (SELECT * FROM test_02
) AS T LEFT JOIN test_02
ON t.id = test.id WHERE t.id IN (2, 6) |
| local_node | SELECT t.name FROM (SELECT * FROM test_03
) AS T LEFT JOIN test_03
ON t.id = test.id WHERE t.id IN (3) |
+------------+----------------------------------------------------------------------------------------------------------------+
4 rows in set (0.01 sec)
mysql> explain select t.name from (select * from test ) as t left join test on t.id = test.id where t.id =1 ;
+------------+--------------------------------------------------------------------------------------------------------+
| DATA_NODE | SQL |
+------------+--------------------------------------------------------------------------------------------------------+
| local_node | SELECT t.name FROM (SELECT * FROM test_01
) AS T LEFT JOIN test_01
ON t.id = test.id WHERE t.id = 1 |
+------------+--------------------------------------------------------------------------------------------------------+
1 row in set (0.01 sec)