Skip to content

Commit 20b231f

Browse files
authored
planner: enable cd-c algorithm by default for join reorder (#66349)
close #66088
1 parent 864cba9 commit 20b231f

34 files changed

Lines changed: 1888 additions & 1976 deletions

pkg/planner/core/casetest/binaryplan/testdata/binary_plan_suite_out.json

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -68,19 +68,19 @@
6868
"SQL": "explain analyze format = 'binary' select sum(t.a) from t join t2",
6969
"BinaryPlan": {
7070
"main": {
71-
"name": "HashAgg_12",
71+
"name": "HashAgg_13",
7272
"children": [
7373
{
74-
"name": "Projection_60",
74+
"name": "Projection_61",
7575
"children": [
7676
{
77-
"name": "HashJoin_31",
77+
"name": "HashJoin_32",
7878
"children": [
7979
{
80-
"name": "IndexReader_36",
80+
"name": "IndexReader_37",
8181
"children": [
8282
{
83-
"name": "IndexFullScan_35",
83+
"name": "IndexFullScan_36",
8484
"cost": 1628000.000001,
8585
"est_rows": 10000,
8686
"act_rows": 2,
@@ -97,13 +97,13 @@
9797
"act_rows": 2,
9898
"task_type": 1,
9999
"store_type": 1,
100-
"operator_info": "index:IndexFullScan_35"
100+
"operator_info": "index:IndexFullScan_36"
101101
},
102102
{
103-
"name": "TableReader_38",
103+
"name": "TableReader_39",
104104
"children": [
105105
{
106-
"name": "TableFullScan_37",
106+
"name": "TableFullScan_38",
107107
"cost": 4546159.475587022,
108108
"est_rows": 10000,
109109
"act_rows": 4,
@@ -120,7 +120,7 @@
120120
"act_rows": 4,
121121
"task_type": 1,
122122
"store_type": 1,
123-
"operator_info": "data:TableFullScan_37"
123+
"operator_info": "data:TableFullScan_38"
124124
}
125125
],
126126
"cost": 1128387.631705868,

pkg/planner/core/casetest/binaryplan/testdata/binary_plan_suite_xut.json

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -68,19 +68,19 @@
6868
"SQL": "explain analyze format = 'binary' select sum(t.a) from t join t2",
6969
"BinaryPlan": {
7070
"main": {
71-
"name": "HashAgg_12",
71+
"name": "HashAgg_13",
7272
"children": [
7373
{
74-
"name": "Projection_60",
74+
"name": "Projection_61",
7575
"children": [
7676
{
77-
"name": "HashJoin_31",
77+
"name": "HashJoin_32",
7878
"children": [
7979
{
80-
"name": "IndexReader_36",
80+
"name": "IndexReader_37",
8181
"children": [
8282
{
83-
"name": "IndexFullScan_35",
83+
"name": "IndexFullScan_36",
8484
"cost": 1628000.000001,
8585
"est_rows": 10000,
8686
"act_rows": 2,
@@ -97,13 +97,13 @@
9797
"act_rows": 2,
9898
"task_type": 1,
9999
"store_type": 1,
100-
"operator_info": "index:IndexFullScan_35"
100+
"operator_info": "index:IndexFullScan_36"
101101
},
102102
{
103-
"name": "TableReader_38",
103+
"name": "TableReader_39",
104104
"children": [
105105
{
106-
"name": "TableFullScan_37",
106+
"name": "TableFullScan_38",
107107
"cost": 4546159.475587022,
108108
"est_rows": 10000,
109109
"act_rows": 4,
@@ -120,7 +120,7 @@
120120
"act_rows": 4,
121121
"task_type": 1,
122122
"store_type": 1,
123-
"operator_info": "data:TableFullScan_37"
123+
"operator_info": "data:TableFullScan_38"
124124
}
125125
],
126126
"cost": 1128387.631705868,

pkg/planner/core/casetest/cbotest/testdata/analyze_suite_out.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@
260260
"│ └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo",
261261
"└─IndexReader(Probe) 12475.01 root index:Selection",
262262
" └─Selection 12475.01 cop[tikv] not(isnull(test.t2.a)), not(isnull(test.t2.c))",
263-
" └─IndexRangeScan 12500.00 cop[tikv] table:t2, index:idx(a, b, c) range: decided by [eq(test.t2.a, test.t1.a) lt(test.t2.b, plus(test.t1.b, 1)) gt(test.t2.b, minus(test.t1.b, 1))], keep order:false, stats:pseudo"
263+
" └─IndexRangeScan 12500.00 cop[tikv] table:t2, index:idx(a, b, c) range: decided by [eq(test.t2.a, test.t1.a) gt(test.t2.b, minus(test.t1.b, 1)) lt(test.t2.b, plus(test.t1.b, 1))], keep order:false, stats:pseudo"
264264
]
265265
},
266266
{

pkg/planner/core/casetest/cbotest/testdata/analyze_suite_xut.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@
260260
"│ └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo",
261261
"└─IndexReader(Probe) 12475.01 root index:Selection",
262262
" └─Selection 12475.01 cop[tikv] not(isnull(test.t2.a)), not(isnull(test.t2.c))",
263-
" └─IndexRangeScan 12500.00 cop[tikv] table:t2, index:idx(a, b, c) range: decided by [eq(test.t2.a, test.t1.a) lt(test.t2.b, plus(test.t1.b, 1)) gt(test.t2.b, minus(test.t1.b, 1))], keep order:false, stats:pseudo"
263+
" └─IndexRangeScan 12500.00 cop[tikv] table:t2, index:idx(a, b, c) range: decided by [eq(test.t2.a, test.t1.a) gt(test.t2.b, minus(test.t1.b, 1)) lt(test.t2.b, plus(test.t1.b, 1))], keep order:false, stats:pseudo"
264264
]
265265
},
266266
{

pkg/planner/core/casetest/hint/testdata/integration_suite_out.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1921,9 +1921,7 @@
19211921
" └─TableReader(Probe) 10000.00 root data:TableFullScan",
19221922
" └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo"
19231923
],
1924-
"Warn": [
1925-
"Warning 1815 leading hint is inapplicable, check if the leading hint table has join conditions with other tables"
1926-
]
1924+
"Warn": null
19271925
}
19281926
]
19291927
},

pkg/planner/core/casetest/hint/testdata/integration_suite_xut.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1921,9 +1921,7 @@
19211921
" └─TableReader(Probe) 10000.00 root data:TableFullScan",
19221922
" └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo"
19231923
],
1924-
"Warn": [
1925-
"Warning 1815 leading hint is inapplicable, check if the leading hint table has join conditions with other tables"
1926-
]
1924+
"Warn": null
19271925
}
19281926
]
19291927
},

pkg/planner/core/casetest/mpp/testdata/integration_suite_out.json

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1705,23 +1705,22 @@
17051705
" │ └─Projection 10000.00 mpp[tiflash] test.t.c1, test.t.c2, test.t.c3, test.t.c4, test.t.c5, cast(test.t.c4, decimal(40,20))->Column#33",
17061706
" │ └─TableFullScan 10000.00 mpp[tiflash] table:t4 keep order:false, stats:pseudo",
17071707
" └─Projection(Probe) 15593.77 mpp[tiflash] test.t.c1, test.t.c2, test.t.c3, test.t.c4, test.t.c5, test.t.c1, test.t.c2, test.t.c3, test.t.c4, test.t.c5, test.t.c1, test.t.c2, test.t.c3, test.t.c4, test.t.c5",
1708-
" └─Projection 15593.77 mpp[tiflash] test.t.c1, test.t.c2, test.t.c3, test.t.c4, test.t.c5, test.t.c1, test.t.c2, test.t.c3, test.t.c4, test.t.c5, test.t.c1, test.t.c2, test.t.c3, test.t.c4, test.t.c5",
1709-
" └─HashJoin 15593.77 mpp[tiflash] inner join, equal:[eq(test.t.c5, test.t.c3)]",
1710-
" ├─ExchangeReceiver(Build) 10000.00 mpp[tiflash] ",
1711-
" │ └─ExchangeSender 10000.00 mpp[tiflash] ExchangeType: HashPartition, Compression: FAST, Hash Cols: [name: Column#29, collate: binary]",
1712-
" │ └─Projection 10000.00 mpp[tiflash] test.t.c1, test.t.c2, test.t.c3, test.t.c4, test.t.c5, cast(test.t.c3, decimal(40,20))->Column#29",
1713-
" │ └─TableFullScan 10000.00 mpp[tiflash] table:t3 keep order:false, stats:pseudo",
1714-
" └─ExchangeReceiver(Probe) 12475.01 mpp[tiflash] ",
1715-
" └─ExchangeSender 12475.01 mpp[tiflash] ExchangeType: HashPartition, Compression: FAST, Hash Cols: [name: test.t.c5, collate: binary]",
1716-
" └─HashJoin 12475.01 mpp[tiflash] inner join, equal:[eq(test.t.c2, test.t.c1)]",
1717-
" ├─ExchangeReceiver(Build) 9980.01 mpp[tiflash] ",
1718-
" │ └─ExchangeSender 9980.01 mpp[tiflash] ExchangeType: HashPartition, Compression: FAST, Hash Cols: [name: test.t.c2, collate: binary]",
1719-
" │ └─Selection 9980.01 mpp[tiflash] not(isnull(test.t.c2)), not(isnull(test.t.c5))",
1720-
" │ └─TableFullScan 10000.00 mpp[tiflash] table:t2 keep order:false, stats:pseudo",
1721-
" └─ExchangeReceiver(Probe) 9990.00 mpp[tiflash] ",
1722-
" └─ExchangeSender 9990.00 mpp[tiflash] ExchangeType: HashPartition, Compression: FAST, Hash Cols: [name: test.t.c1, collate: binary]",
1723-
" └─Selection 9990.00 mpp[tiflash] not(isnull(test.t.c1))",
1724-
" └─TableFullScan 10000.00 mpp[tiflash] table:t1 keep order:false, stats:pseudo"
1708+
" └─HashJoin 15593.77 mpp[tiflash] inner join, equal:[eq(test.t.c5, test.t.c3)]",
1709+
" ├─ExchangeReceiver(Build) 10000.00 mpp[tiflash] ",
1710+
" │ └─ExchangeSender 10000.00 mpp[tiflash] ExchangeType: HashPartition, Compression: FAST, Hash Cols: [name: Column#29, collate: binary]",
1711+
" │ └─Projection 10000.00 mpp[tiflash] test.t.c1, test.t.c2, test.t.c3, test.t.c4, test.t.c5, cast(test.t.c3, decimal(40,20))->Column#29",
1712+
" │ └─TableFullScan 10000.00 mpp[tiflash] table:t3 keep order:false, stats:pseudo",
1713+
" └─ExchangeReceiver(Probe) 12475.01 mpp[tiflash] ",
1714+
" └─ExchangeSender 12475.01 mpp[tiflash] ExchangeType: HashPartition, Compression: FAST, Hash Cols: [name: test.t.c5, collate: binary]",
1715+
" └─HashJoin 12475.01 mpp[tiflash] inner join, equal:[eq(test.t.c2, test.t.c1)]",
1716+
" ├─ExchangeReceiver(Build) 9980.01 mpp[tiflash] ",
1717+
" │ └─ExchangeSender 9980.01 mpp[tiflash] ExchangeType: HashPartition, Compression: FAST, Hash Cols: [name: test.t.c2, collate: binary]",
1718+
" │ └─Selection 9980.01 mpp[tiflash] not(isnull(test.t.c2)), not(isnull(test.t.c5))",
1719+
" │ └─TableFullScan 10000.00 mpp[tiflash] table:t2 keep order:false, stats:pseudo",
1720+
" └─ExchangeReceiver(Probe) 9990.00 mpp[tiflash] ",
1721+
" └─ExchangeSender 9990.00 mpp[tiflash] ExchangeType: HashPartition, Compression: FAST, Hash Cols: [name: test.t.c1, collate: binary]",
1722+
" └─Selection 9990.00 mpp[tiflash] not(isnull(test.t.c1))",
1723+
" └─TableFullScan 10000.00 mpp[tiflash] table:t1 keep order:false, stats:pseudo"
17251724
]
17261725
},
17271726
{

pkg/planner/core/casetest/mpp/testdata/integration_suite_xut.json

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1705,23 +1705,22 @@
17051705
" │ └─Projection 10000.00 mpp[tiflash] test.t.c1, test.t.c2, test.t.c3, test.t.c4, test.t.c5, cast(test.t.c4, decimal(40,20))->Column#33",
17061706
" │ └─TableFullScan 10000.00 mpp[tiflash] table:t4 keep order:false, stats:pseudo",
17071707
" └─Projection(Probe) 15593.77 mpp[tiflash] test.t.c1, test.t.c2, test.t.c3, test.t.c4, test.t.c5, test.t.c1, test.t.c2, test.t.c3, test.t.c4, test.t.c5, test.t.c1, test.t.c2, test.t.c3, test.t.c4, test.t.c5",
1708-
" └─Projection 15593.77 mpp[tiflash] test.t.c1, test.t.c2, test.t.c3, test.t.c4, test.t.c5, test.t.c1, test.t.c2, test.t.c3, test.t.c4, test.t.c5, test.t.c1, test.t.c2, test.t.c3, test.t.c4, test.t.c5",
1709-
" └─HashJoin 15593.77 mpp[tiflash] inner join, equal:[eq(test.t.c5, test.t.c3)]",
1710-
" ├─ExchangeReceiver(Build) 10000.00 mpp[tiflash] ",
1711-
" │ └─ExchangeSender 10000.00 mpp[tiflash] ExchangeType: HashPartition, Compression: FAST, Hash Cols: [name: Column#29, collate: binary]",
1712-
" │ └─Projection 10000.00 mpp[tiflash] test.t.c1, test.t.c2, test.t.c3, test.t.c4, test.t.c5, cast(test.t.c3, decimal(40,20))->Column#29",
1713-
" │ └─TableFullScan 10000.00 mpp[tiflash] table:t3 keep order:false, stats:pseudo",
1714-
" └─ExchangeReceiver(Probe) 12475.01 mpp[tiflash] ",
1715-
" └─ExchangeSender 12475.01 mpp[tiflash] ExchangeType: HashPartition, Compression: FAST, Hash Cols: [name: test.t.c5, collate: binary]",
1716-
" └─HashJoin 12475.01 mpp[tiflash] inner join, equal:[eq(test.t.c2, test.t.c1)]",
1717-
" ├─ExchangeReceiver(Build) 9980.01 mpp[tiflash] ",
1718-
" │ └─ExchangeSender 9980.01 mpp[tiflash] ExchangeType: HashPartition, Compression: FAST, Hash Cols: [name: test.t.c2, collate: binary]",
1719-
" │ └─Selection 9980.01 mpp[tiflash] not(isnull(test.t.c2)), not(isnull(test.t.c5))",
1720-
" │ └─TableFullScan 10000.00 mpp[tiflash] table:t2 keep order:false, stats:pseudo",
1721-
" └─ExchangeReceiver(Probe) 9990.00 mpp[tiflash] ",
1722-
" └─ExchangeSender 9990.00 mpp[tiflash] ExchangeType: HashPartition, Compression: FAST, Hash Cols: [name: test.t.c1, collate: binary]",
1723-
" └─Selection 9990.00 mpp[tiflash] not(isnull(test.t.c1))",
1724-
" └─TableFullScan 10000.00 mpp[tiflash] table:t1 keep order:false, stats:pseudo"
1708+
" └─HashJoin 15593.77 mpp[tiflash] inner join, equal:[eq(test.t.c5, test.t.c3)]",
1709+
" ├─ExchangeReceiver(Build) 10000.00 mpp[tiflash] ",
1710+
" │ └─ExchangeSender 10000.00 mpp[tiflash] ExchangeType: HashPartition, Compression: FAST, Hash Cols: [name: Column#29, collate: binary]",
1711+
" │ └─Projection 10000.00 mpp[tiflash] test.t.c1, test.t.c2, test.t.c3, test.t.c4, test.t.c5, cast(test.t.c3, decimal(40,20))->Column#29",
1712+
" │ └─TableFullScan 10000.00 mpp[tiflash] table:t3 keep order:false, stats:pseudo",
1713+
" └─ExchangeReceiver(Probe) 12475.01 mpp[tiflash] ",
1714+
" └─ExchangeSender 12475.01 mpp[tiflash] ExchangeType: HashPartition, Compression: FAST, Hash Cols: [name: test.t.c5, collate: binary]",
1715+
" └─HashJoin 12475.01 mpp[tiflash] inner join, equal:[eq(test.t.c2, test.t.c1)]",
1716+
" ├─ExchangeReceiver(Build) 9980.01 mpp[tiflash] ",
1717+
" │ └─ExchangeSender 9980.01 mpp[tiflash] ExchangeType: HashPartition, Compression: FAST, Hash Cols: [name: test.t.c2, collate: binary]",
1718+
" │ └─Selection 9980.01 mpp[tiflash] not(isnull(test.t.c2)), not(isnull(test.t.c5))",
1719+
" │ └─TableFullScan 10000.00 mpp[tiflash] table:t2 keep order:false, stats:pseudo",
1720+
" └─ExchangeReceiver(Probe) 9990.00 mpp[tiflash] ",
1721+
" └─ExchangeSender 9990.00 mpp[tiflash] ExchangeType: HashPartition, Compression: FAST, Hash Cols: [name: test.t.c1, collate: binary]",
1722+
" └─Selection 9990.00 mpp[tiflash] not(isnull(test.t.c1))",
1723+
" └─TableFullScan 10000.00 mpp[tiflash] table:t1 keep order:false, stats:pseudo"
17251724
]
17261725
},
17271726
{

pkg/planner/core/casetest/rule/testdata/cdc_join_reorder_suite_out.json

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1264,17 +1264,16 @@
12641264
"SQL": "explain format = 'plan_tree' select * from t1 where exists (select 1 from t2 inner join t3 on t2.id=t3.id left join t4 on t4.id=t3.id join t5 on t2.id=t5.id where (t3.name like 'test3' or t4.name like 'test4') and t2.id = t1.id)",
12651265
"Plan": [
12661266
"MergeJoin root semi join, left side:TableReader, left key:test.t1.id, right key:test.t2.id",
1267-
"├─Projection(Build) root test.t2.id",
1268-
"│ └─Selection root or(like(test.t3.name, \"test3\", 92), like(test.t4.name, \"test4\", 92))",
1267+
"├─MergeJoin(Build) root inner join, left key:test.t2.id, right key:test.t5.id",
1268+
"│ ├─TableReader(Build) root data:TableFullScan",
1269+
"│ │ └─TableFullScan cop[tikv] table:t5 keep order:true",
1270+
"│ └─Selection(Probe) root or(like(test.t3.name, \"test3\", 92), like(test.t4.name, \"test4\", 92))",
12691271
"│ └─IndexJoin root left outer join, inner:TableReader, left side:MergeJoin, outer key:test.t3.id, inner key:test.t4.id, equal cond:eq(test.t3.id, test.t4.id)",
1270-
"│ ├─MergeJoin(Build) root inner join, left key:test.t2.id, right key:test.t5.id",
1272+
"│ ├─MergeJoin(Build) root inner join, left key:test.t2.id, right key:test.t3.id",
12711273
"│ │ ├─TableReader(Build) root data:TableFullScan",
1272-
"│ │ │ └─TableFullScan cop[tikv] table:t5 keep order:true",
1273-
"│ │ └─MergeJoin(Probe) root inner join, left key:test.t2.id, right key:test.t3.id",
1274-
"│ │ ├─TableReader(Build) root data:TableFullScan",
1275-
"│ │ │ └─TableFullScan cop[tikv] table:t3 keep order:true",
1276-
"│ │ └─TableReader(Probe) root data:TableFullScan",
1277-
"│ │ └─TableFullScan cop[tikv] table:t2 keep order:true",
1274+
"│ │ │ └─TableFullScan cop[tikv] table:t3 keep order:true",
1275+
"│ │ └─TableReader(Probe) root data:TableFullScan",
1276+
"│ │ └─TableFullScan cop[tikv] table:t2 keep order:true",
12781277
"│ └─TableReader(Probe) root data:TableRangeScan",
12791278
"│ └─TableRangeScan cop[tikv] table:t4 range: decided by [test.t3.id], keep order:false",
12801279
"└─TableReader(Probe) root data:TableFullScan",

0 commit comments

Comments
 (0)