Please answer these questions before submitting your issue. Thanks!
In TiDB, it will convert intersect/except into a hash join with nulleq join condition:
As you can see, HashJoin_7 is a hash join with nulleq join condition
However, if the query is a little bit complex, TiDB optimizer will generate a CARTESIAN semi join
Bug Report
Please answer these questions before submitting your issue. Thanks! In TiDB, it will convert intersect/except into a hash join with nulleq join condition:
As you can see,
HashJoin_7
is a hash join with nulleq join condition However, if the query is a little bit complex, TiDB optimizer will generate a CARTESIAN semi joinThe direct cause seems in https://github.com/pingcap/tidb/tree/c091dba89718599dc1b3d3e45f9b0308a8d49ef0/pkg/planner/core/operator/logicalop/logical_join.go#L200
For inner/semi join, it will collect all join's condition together with the predicate, and call
LogicalJoin::extractOnCondition
to re-extract the condition, and in https://github.com/pingcap/tidb/tree/c091dba89718599dc1b3d3e45f9b0308a8d49ef0/pkg/planner/core/operator/logicalop/logical_join.go#L1214 only eq is treated as equal condition: https://github.com/pingcap/tidb/tree/c091dba89718599dc1b3d3e45f9b0308a8d49ef0/pkg/planner/core/operator/logicalop/logical_join.go#L1257-L12611. Minimal reproduce step (Required)
2. What did you expect to see? (Required)
3. What did you see instead (Required)
4. What is your TiDB version? (Required)