-
Notifications
You must be signed in to change notification settings - Fork 319
Closed
Labels
Milestone
Description
-
dble version:
5.6.29-dble-9.9.9.9-3bc0fd1498a4e28065918507d64ee63ca440d386-20200210030514 -
preconditions :
no -
configs:
schema.xml
<schema name="schema1" sqlMaxLimit="100" dataNode="dn5">
<table name="sharding_two_node" dataNode="dn1,dn2" rule="hash-two"/>
<table name="sharding_two_node2" dataNode="dn1,dn2" rule="hash-two"/>
</schema>
rule.xml
server.xml
- steps:
step1. prepare data in dble
CREATE TABLE `sharding_two_node` (
`id` int(11) DEFAULT NULL,
`c_flag` int(11) DEFAULT NULL,
`c_decimal` float DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
CREATE TABLE `sharding_two_node2` ( `id` int(11) DEFAULT NULL, `c_flag` int(11) DEFAULT NULL, `c_decimal` float DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
insert into sharding_two_node values(2,2,2);
insert into sharding_two_node2 values(2,2,2);
step2. get explain of sql:
```mysql
explain select b.*,a.* from sharding_two_node a join sharding_two_node2 b where a.id =b.id and (a.c_decimal=1 or (( a.id =1 and b.id=1) or ( a.c_flag=b.c_flag and a.id =2 ))) \G
*************************** 1. row ***************************
DATA_NODE: dn1_0
TYPE: BASE SQL
SQL/REF: select `a`.`id`,`a`.`c_flag`,`a`.`c_decimal`,`b`.`id`,`b`.`c_flag`,`b`.`c_decimal` from `sharding_two_node` `a` join `sharding_two_node2` `b` on `a`.`id` = `b`.`id` where ((`a`.`id` = 1) OR (`a`.`id` = 2) OR (a.c_decimal IN (1))) AND (((`a`.`id` = 1) AND (`b`.`id` = 1)) OR ((`a`.`c_flag` = `b`.`c_flag`) AND (`a`.`id` = 2)) OR (a.c_decimal IN (1)))
*************************** 2. row ***************************
DATA_NODE: dn2_0
TYPE: BASE SQL
SQL/REF: select `a`.`id`,`a`.`c_flag`,`a`.`c_decimal`,`b`.`id`,`b`.`c_flag`,`b`.`c_decimal` from `sharding_two_node` `a` join `sharding_two_node2` `b` on `a`.`id` = `b`.`id` where ((`a`.`id` = 1) OR (`a`.`id` = 2) OR (a.c_decimal IN (1))) AND (((`a`.`id` = 1) AND (`b`.`id` = 1)) OR ((`a`.`c_flag` = `b`.`c_flag`) AND (`a`.`id` = 2)) OR (a.c_decimal IN (1)))
*************************** 3. row ***************************
DATA_NODE: merge_1
TYPE: MERGE
SQL/REF: dn1_0; dn2_0
*************************** 4. row ***************************
DATA_NODE: shuffle_field_1
TYPE: SHUFFLE_FIELD
SQL/REF: merge_1
4 rows in set (0.01 sec)
- expect result:
in result of explain, the order of table a and b are valid - real result:
- in step2,
*************************** 1. row ***************************
DATA_NODE: dn1_0
TYPE: BASE SQL
SQL/REF: selecta
.id
,a
.c_flag
,a
.c_decimal
,b
.id
,b
.c_flag
,b
.c_decimal
fromsharding_two_node
a
joinsharding_two_node2
b
ona
.id
=b
.id
where ((a
.id
= 1) OR (a
.id
= 2) OR (a.c_decimal IN (1))) AND (((a
.id
= 1) AND (b
.id
= 1)) OR ((a
.c_flag
=b
.c_flag
) AND (a
.id
= 2)) OR (a.c_decimal IN (1)))
- in step2,
select a
.id
,a
.c_flag
,a
.c_decimal
,b
.id
,b
.c_flag
,b
.c_decimal
from ...
is odds, some times it's:
select b
.id
,b
.c_flag
,b
.c_decimal
,a
.id
,a
.c_flag
,a
.c_decimal
from ...
- supplements:
1.