From 3ed911a656701bcf21370b7cde0de3940bb3d382 Mon Sep 17 00:00:00 2001 From: guo-shaoge Date: Sun, 25 Apr 2021 11:47:55 +0800 Subject: [PATCH] cherry pick #24180 to release-5.0 Signed-off-by: ti-srebot --- planner/core/integration_test.go | 24 ++ .../testdata/integration_serial_suite_in.json | 23 ++ .../integration_serial_suite_out.json | 306 ++++++++++++++++++ .../core/testdata/integration_suite_out.json | 57 ++++ 4 files changed, 410 insertions(+) diff --git a/planner/core/integration_test.go b/planner/core/integration_test.go index 5f8db1296e7ce..cc40982f79b73 100644 --- a/planner/core/integration_test.go +++ b/planner/core/integration_test.go @@ -3019,6 +3019,30 @@ func (s *testIntegrationSerialSuite) TestMppAggWithJoin(c *C) { } } +<<<<<<< HEAD +======= +func (s *testIntegrationSerialSuite) TestLimitIndexLookUpKeepOrder(c *C) { + tk := testkit.NewTestKit(c, s.store) + tk.MustExec("use test") + tk.MustExec("drop table if exists t;") + tk.MustExec("create table t(a int, b int, c int, d int, index idx(a,b,c));") + + var input []string + var output []struct { + SQL string + Plan []string + } + s.testData.GetTestCases(c, &input, &output) + for i, tt := range input { + s.testData.OnRecord(func() { + output[i].SQL = tt + output[i].Plan = s.testData.ConvertRowsToStrings(tk.MustQuery(tt).Rows()) + }) + tk.MustQuery(tt).Check(testkit.Rows(output[i].Plan...)) + } +} + +>>>>>>> fb676b769... Revert "planner: donot prune all columns for Projection (#24024)" (#24180) func (s *testIntegrationSuite) TestDecorrelateInnerJoinInSubquery(c *C) { tk := testkit.NewTestKit(c, s.store) diff --git a/planner/core/testdata/integration_serial_suite_in.json b/planner/core/testdata/integration_serial_suite_in.json index 23bd97cd16c33..f2f9666cd2ddb 100644 --- a/planner/core/testdata/integration_serial_suite_in.json +++ b/planner/core/testdata/integration_serial_suite_in.json @@ -251,7 +251,30 @@ "desc format = 'brief' select * from t join ( select /*+ hash_agg()*/ count(*) as a from t) as A on A.a = t.id", "desc format = 'brief' select sum(b) from (select t.id, t1.id as b from t join t t1 on t.id=t1.id)A group by id", "desc format = 'brief' select * from (select id from t group by id) C join (select sum(value),id from t group by id)B on C.id=B.id", +<<<<<<< HEAD "desc format = 'brief' select * from (select id from t group by id) C join (select sum(b),id from (select t.id, t1.id as b from t join (select id, count(*) as c from t group by id) t1 on t.id=t1.id)A group by id)B on C.id=b.id" +======= + "desc format = 'brief' select * from (select id from t group by id) C join (select sum(b),id from (select t.id, t1.id as b from t join (select id, count(*) as c from t group by id) t1 on t.id=t1.id)A group by id)B on C.id=b.id", + "desc format = 'brief' select * from t join t t1 on t.id = t1.id order by t.value limit 1", + "desc format = 'brief' select * from t join t t1 on t.id = t1.id order by t.value % 100 limit 1", + "desc format = 'brief' select count(*) from (select t.id, t.value v1 from t join t t1 on t.id = t1.id order by t.value limit 20) v group by v.v1" + ] + }, + { + "name": "TestIndexMerge", + "cases": [ + "desc format='brief' select /*+ use_index_merge(t) */ * from t where a =1 or (b=1 and b+2>1)", + "desc format='brief' select /*+ use_index_merge(t) */ * from t where a =1 or (b=1 and length(b)=1)", + "desc format='brief' select /*+ use_index_merge(t) */ * from t where (a=1 and length(a)=1) or (b=1 and length(b)=1)", + "desc format='brief' select /*+ use_index_merge(t) */ * from t where (a=1 and length(b)=1) or (b=1 and length(a)=1)" + ] + }, + { + "name": "TestLimitIndexLookUpKeepOrder", + "cases": [ + "desc format = 'brief' select * from t where a = 1 and b > 2 and b < 10 and d = 10 order by b,c limit 10", + "desc format = 'brief' select * from t where a = 1 and b > 2 and b < 10 and d = 10 order by b desc, c desc limit 10" +>>>>>>> fb676b769... Revert "planner: donot prune all columns for Projection (#24024)" (#24180) ] } ] diff --git a/planner/core/testdata/integration_serial_suite_out.json b/planner/core/testdata/integration_serial_suite_out.json index cb1c259385607..35eee21172ea5 100644 --- a/planner/core/testdata/integration_serial_suite_out.json +++ b/planner/core/testdata/integration_serial_suite_out.json @@ -45,6 +45,182 @@ ] }, { +<<<<<<< HEAD +======= + "Name": "TestVerboseExplain", + "Cases": [ + { + "SQL": "explain format = 'verbose' select count(*) from t3", + "Plan": [ + "StreamAgg_20 1.00 137.00 root funcs:count(Column#9)->Column#4", + "└─TableReader_21 1.00 9.68 root data:StreamAgg_8", + " └─StreamAgg_8 1.00 12.68 cop[tikv] funcs:count(1)->Column#9", + " └─TableFullScan_18 3.00 128.00 cop[tikv] table:t3 keep order:false" + ] + }, + { + "SQL": "explain format = 'verbose' select count(*) from t2", + "Plan": [ + "StreamAgg_25 1.00 69.50 root funcs:count(Column#7)->Column#4", + "└─TableReader_26 1.00 5.17 root data:StreamAgg_9", + " └─StreamAgg_9 1.00 8.18 batchCop[tiflash] funcs:count(1)->Column#7", + " └─TableFullScan_24 3.00 60.50 batchCop[tiflash] table:t2 keep order:false" + ] + }, + { + "SQL": "explain format = 'verbose' select * from t3 order by a", + "Plan": [ + "Sort_4 3.00 45.85 root test.t3.a", + "└─TableReader_8 3.00 11.78 root data:TableFullScan_7", + " └─TableFullScan_7 3.00 128.00 cop[tikv] table:t3 keep order:false" + ] + }, + { + "SQL": "explain format = 'verbose' select * from t3 order by b", + "Plan": [ + "Sort_4 3.00 45.85 root test.t3.b", + "└─TableReader_8 3.00 11.78 root data:TableFullScan_7", + " └─TableFullScan_7 3.00 128.00 cop[tikv] table:t3 keep order:false" + ] + }, + { + "SQL": "explain format = 'verbose' select * from t3 order by a limit 1", + "Plan": [ + "TopN_7 1.00 13.22 root test.t3.a, offset:0, count:1", + "└─TableReader_16 1.00 10.22 root data:TopN_15", + " └─TopN_15 1.00 0.00 cop[tikv] test.t3.a, offset:0, count:1", + " └─TableFullScan_14 3.00 128.00 cop[tikv] table:t3 keep order:false" + ] + }, + { + "SQL": "explain format = 'verbose' select * from t3 order by b limit 1", + "Plan": [ + "TopN_7 1.00 13.22 root test.t3.b, offset:0, count:1", + "└─TableReader_16 1.00 10.22 root data:TopN_15", + " └─TopN_15 1.00 0.00 cop[tikv] test.t3.b, offset:0, count:1", + " └─TableFullScan_14 3.00 128.00 cop[tikv] table:t3 keep order:false" + ] + }, + { + "SQL": "explain format = 'verbose' select count(*) from t2 group by a", + "Plan": [ + "TableReader_24 3.00 77.00 root data:ExchangeSender_23", + "└─ExchangeSender_23 3.00 77.00 batchCop[tiflash] ExchangeType: PassThrough", + " └─Projection_22 3.00 0.00 batchCop[tiflash] Column#4", + " └─HashAgg_8 3.00 77.00 batchCop[tiflash] group by:test.t2.a, funcs:count(1)->Column#4", + " └─ExchangeReceiver_21 3.00 68.00 batchCop[tiflash] ", + " └─ExchangeSender_20 3.00 68.00 batchCop[tiflash] ExchangeType: HashPartition, Hash Cols: test.t2.a", + " └─TableFullScan_19 3.00 65.00 batchCop[tiflash] table:t2 keep order:false" + ] + }, + { + "SQL": "explain format = 'verbose' select count(*) from t3 where b = 0", + "Plan": [ + "StreamAgg_10 1.00 1.33 root funcs:count(1)->Column#4", + "└─IndexReader_15 0.00 1.33 root index:IndexRangeScan_14", + " └─IndexRangeScan_14 0.00 20.00 cop[tikv] table:t3, index:c(b) range:[0,0], keep order:false" + ] + }, + { + "SQL": "explain format = 'verbose' select /*+ use_index(t3, c) */ count(a) from t3 where b = 0", + "Plan": [ + "StreamAgg_10 1.00 19.33 root funcs:count(test.t3.a)->Column#4", + "└─IndexLookUp_17 0.00 19.33 root ", + " ├─IndexRangeScan_15(Build) 0.00 20.00 cop[tikv] table:t3, index:c(b) range:[0,0], keep order:false", + " └─TableRowIDScan_16(Probe) 0.00 20.00 cop[tikv] table:t3 keep order:false" + ] + }, + { + "SQL": "explain format = 'verbose' select count(*) from t2 where a = 0", + "Plan": [ + "StreamAgg_11 1.00 4.93 root funcs:count(1)->Column#4", + "└─TableReader_23 0.00 4.93 root data:Selection_22", + " └─Selection_22 0.00 74.00 cop[tiflash] eq(test.t2.a, 0)", + " └─TableFullScan_21 3.00 65.00 cop[tiflash] table:t2 keep order:false" + ] + }, + { + "SQL": "explain format = 'verbose' select count(*) from t3 t join t3 on t.a = t3.b", + "Plan": [ + "StreamAgg_10 1.00 60.22 root funcs:count(1)->Column#7", + "└─HashJoin_40 3.00 51.22 root inner join, equal:[eq(test.t3.a, test.t3.b)]", + " ├─IndexReader_28(Build) 3.00 11.66 root index:IndexFullScan_27", + " │ └─IndexFullScan_27 3.00 150.50 cop[tikv] table:t3, index:c(b) keep order:false", + " └─TableReader_26(Probe) 3.00 10.76 root data:Selection_25", + " └─Selection_25 3.00 137.00 cop[tikv] not(isnull(test.t3.a))", + " └─TableFullScan_24 3.00 128.00 cop[tikv] table:t keep order:false" + ] + }, + { + "SQL": "explain format = 'verbose' select count(*) from t1 join t2 on t1.a = t2.a", + "Plan": [ + "StreamAgg_12 1.00 20.77 root funcs:count(1)->Column#7", + "└─TableReader_44 3.00 235.38 root data:ExchangeSender_43", + " └─ExchangeSender_43 3.00 235.38 cop[tiflash] ExchangeType: PassThrough", + " └─HashJoin_40 3.00 235.38 cop[tiflash] inner join, equal:[eq(test.t1.a, test.t2.a)]", + " ├─ExchangeReceiver_19(Build) 3.00 77.00 cop[tiflash] ", + " │ └─ExchangeSender_18 3.00 77.00 cop[tiflash] ExchangeType: Broadcast", + " │ └─Selection_17 3.00 74.00 cop[tiflash] not(isnull(test.t1.a))", + " │ └─TableFullScan_16 3.00 65.00 cop[tiflash] table:t1 keep order:false", + " └─Selection_21(Probe) 3.00 74.00 cop[tiflash] not(isnull(test.t2.a))", + " └─TableFullScan_20 3.00 65.00 cop[tiflash] table:t2 keep order:false" + ] + }, + { + "SQL": "explain format = 'verbose' select count(*) from t1 join t2 on t1.a = t2.a join t3 on t1.b = t3.b", + "Plan": [ + "StreamAgg_15 1.00 62.68 root funcs:count(1)->Column#10", + "└─HashJoin_65 3.00 53.68 root inner join, equal:[eq(test.t1.b, test.t3.b)]", + " ├─IndexReader_53(Build) 3.00 11.66 root index:IndexFullScan_52", + " │ └─IndexFullScan_52 3.00 150.50 cop[tikv] table:t3, index:c(b) keep order:false", + " └─TableReader_39(Probe) 3.00 264.38 root data:ExchangeSender_38", + " └─ExchangeSender_38 3.00 264.38 cop[tiflash] ExchangeType: PassThrough", + " └─HashJoin_29 3.00 264.38 cop[tiflash] inner join, equal:[eq(test.t1.a, test.t2.a)]", + " ├─ExchangeReceiver_35(Build) 3.00 106.00 cop[tiflash] ", + " │ └─ExchangeSender_34 3.00 106.00 cop[tiflash] ExchangeType: Broadcast", + " │ └─Selection_33 3.00 103.00 cop[tiflash] not(isnull(test.t1.a)), not(isnull(test.t1.b))", + " │ └─TableFullScan_32 3.00 94.00 cop[tiflash] table:t1 keep order:false", + " └─Selection_37(Probe) 3.00 74.00 cop[tiflash] not(isnull(test.t2.a))", + " └─TableFullScan_36 3.00 65.00 cop[tiflash] table:t2 keep order:false" + ] + }, + { + "SQL": "explain format = 'verbose' select (2) in (select count(*) from t1) from (select t.b < (select t.b from t2 limit 1 ) from t3 t) t", + "Plan": [ + "HashJoin_19 3.00 113.61 root CARTESIAN left outer semi join", + "├─Selection_38(Build) 0.80 11.18 root eq(2, Column#18)", + "│ └─StreamAgg_59 1.00 69.50 root funcs:count(Column#27)->Column#18", + "│ └─TableReader_60 1.00 5.17 root data:StreamAgg_43", + "│ └─StreamAgg_43 1.00 8.18 batchCop[tiflash] funcs:count(1)->Column#27", + "│ └─TableFullScan_58 3.00 60.50 batchCop[tiflash] table:t1 keep order:false", + "└─Apply_21(Probe) 3.00 82.03 root CARTESIAN left outer join", + " ├─TableReader_23(Build) 3.00 10.16 root data:TableFullScan_22", + " │ └─TableFullScan_22 3.00 128.00 cop[tikv] table:t keep order:false", + " └─Limit_27(Probe) 1.00 5.36 root offset:0, count:1", + " └─TableReader_33 1.00 5.36 root data:Limit_32", + " └─Limit_32 1.00 56.00 cop[tikv] offset:0, count:1", + " └─TableFullScan_30 1.00 56.00 cop[tikv] table:t2 keep order:false" + ] + }, + { + "SQL": "explain format = 'verbose' select /*+ merge_join(t1) */ count(*) from t1 join t2 on t1.a = t2.a", + "Plan": [ + "StreamAgg_11 1.00 59.65 root funcs:count(1)->Column#7", + "└─MergeJoin_29 3.00 50.65 root inner join, left key:test.t1.a, right key:test.t2.a", + " ├─Sort_27(Build) 3.00 20.83 root test.t2.a", + " │ └─TableReader_26 3.00 6.56 root data:Selection_25", + " │ └─Selection_25 3.00 74.00 cop[tiflash] not(isnull(test.t2.a))", + " │ └─TableFullScan_24 3.00 65.00 cop[tiflash] table:t2 keep order:false", + " └─Sort_20(Probe) 3.00 20.83 root test.t1.a", + " └─TableReader_19 3.00 6.56 root data:Selection_18", + " └─Selection_18 3.00 74.00 cop[tiflash] not(isnull(test.t1.a))", + " └─TableFullScan_17 3.00 65.00 cop[tiflash] table:t1 keep order:false" + ] + } + ] + }, + { +>>>>>>> fb676b769... Revert "planner: donot prune all columns for Projection (#24024)" (#24180) "Name": "TestPushDownToTiFlashWithKeepOrder", "Cases": [ { @@ -2252,6 +2428,136 @@ " └─Selection(Probe) 9990.00 batchCop[tiflash] not(isnull(test.t.id))", " └─TableFullScan 10000.00 batchCop[tiflash] table:t keep order:false, stats:pseudo" ] +<<<<<<< HEAD +======= + }, + { + "SQL": "desc format = 'brief' select * from t join t t1 on t.id = t1.id order by t.value limit 1", + "Plan": [ + "TopN 1.00 root test.t.value, offset:0, count:1", + "└─TableReader 1.00 root data:ExchangeSender", + " └─ExchangeSender 1.00 batchCop[tiflash] ExchangeType: PassThrough", + " └─TopN 1.00 batchCop[tiflash] test.t.value, offset:0, count:1", + " └─HashJoin 12487.50 batchCop[tiflash] inner join, equal:[eq(test.t.id, test.t.id)]", + " ├─ExchangeReceiver(Build) 9990.00 batchCop[tiflash] ", + " │ └─ExchangeSender 9990.00 batchCop[tiflash] ExchangeType: Broadcast", + " │ └─Selection 9990.00 batchCop[tiflash] not(isnull(test.t.id))", + " │ └─TableFullScan 10000.00 batchCop[tiflash] table:t keep order:false, stats:pseudo", + " └─Selection(Probe) 9990.00 batchCop[tiflash] not(isnull(test.t.id))", + " └─TableFullScan 10000.00 batchCop[tiflash] table:t1 keep order:false, stats:pseudo" + ] + }, + { + "SQL": "desc format = 'brief' select * from t join t t1 on t.id = t1.id order by t.value % 100 limit 1", + "Plan": [ + "Projection 1.00 root test.t.id, test.t.value, test.t.id, test.t.value", + "└─TopN 1.00 root Column#7, offset:0, count:1", + " └─Projection 12487.50 root test.t.id, test.t.value, test.t.id, test.t.value, mod(test.t.value, 100)->Column#7", + " └─TableReader 12487.50 root data:ExchangeSender", + " └─ExchangeSender 12487.50 cop[tiflash] ExchangeType: PassThrough", + " └─HashJoin 12487.50 cop[tiflash] inner join, equal:[eq(test.t.id, test.t.id)]", + " ├─ExchangeReceiver(Build) 9990.00 cop[tiflash] ", + " │ └─ExchangeSender 9990.00 cop[tiflash] ExchangeType: Broadcast", + " │ └─Selection 9990.00 cop[tiflash] not(isnull(test.t.id))", + " │ └─TableFullScan 10000.00 cop[tiflash] table:t keep order:false, stats:pseudo", + " └─Selection(Probe) 9990.00 cop[tiflash] not(isnull(test.t.id))", + " └─TableFullScan 10000.00 cop[tiflash] table:t1 keep order:false, stats:pseudo" + ] + }, + { + "SQL": "desc format = 'brief' select count(*) from (select t.id, t.value v1 from t join t t1 on t.id = t1.id order by t.value limit 20) v group by v.v1", + "Plan": [ + "HashAgg 20.00 root group by:test.t.value, funcs:count(1)->Column#7", + "└─TopN 20.00 root test.t.value, offset:0, count:20", + " └─TableReader 20.00 root data:ExchangeSender", + " └─ExchangeSender 20.00 batchCop[tiflash] ExchangeType: PassThrough", + " └─TopN 20.00 batchCop[tiflash] test.t.value, offset:0, count:20", + " └─HashJoin 12487.50 batchCop[tiflash] inner join, equal:[eq(test.t.id, test.t.id)]", + " ├─ExchangeReceiver(Build) 9990.00 batchCop[tiflash] ", + " │ └─ExchangeSender 9990.00 batchCop[tiflash] ExchangeType: Broadcast", + " │ └─Selection 9990.00 batchCop[tiflash] not(isnull(test.t.id))", + " │ └─TableFullScan 10000.00 batchCop[tiflash] table:t keep order:false, stats:pseudo", + " └─Selection(Probe) 9990.00 batchCop[tiflash] not(isnull(test.t.id))", + " └─TableFullScan 10000.00 batchCop[tiflash] table:t1 keep order:false, stats:pseudo" + ] + } + ] + }, + { + "Name": "TestIndexMerge", + "Cases": [ + { + "SQL": "desc format='brief' select /*+ use_index_merge(t) */ * from t where a =1 or (b=1 and b+2>1)", + "Plan": [ + "IndexMerge 8.00 root ", + "├─IndexRangeScan(Build) 1.00 cop[tikv] table:t, index:a(a) range:[1,1], keep order:false", + "├─Selection(Build) 0.80 cop[tikv] 1", + "│ └─IndexRangeScan 1.00 cop[tikv] table:t, index:b(b) range:[1,1], keep order:false", + "└─TableRowIDScan(Probe) 8.00 cop[tikv] table:t keep order:false" + ], + "Warnings": null + }, + { + "SQL": "desc format='brief' select /*+ use_index_merge(t) */ * from t where a =1 or (b=1 and length(b)=1)", + "Plan": [ + "IndexMerge 1.72 root ", + "├─IndexRangeScan(Build) 1.00 cop[tikv] table:t, index:a(a) range:[1,1], keep order:false", + "├─Selection(Build) 0.80 cop[tikv] eq(length(cast(1, var_string(20))), 1)", + "│ └─IndexRangeScan 1.00 cop[tikv] table:t, index:b(b) range:[1,1], keep order:false", + "└─TableRowIDScan(Probe) 1.72 cop[tikv] table:t keep order:false" + ], + "Warnings": null + }, + { + "SQL": "desc format='brief' select /*+ use_index_merge(t) */ * from t where (a=1 and length(a)=1) or (b=1 and length(b)=1)", + "Plan": [ + "IndexMerge 1.54 root ", + "├─Selection(Build) 0.80 cop[tikv] eq(length(cast(1, var_string(20))), 1)", + "│ └─IndexRangeScan 1.00 cop[tikv] table:t, index:a(a) range:[1,1], keep order:false", + "├─Selection(Build) 0.80 cop[tikv] eq(length(cast(1, var_string(20))), 1)", + "│ └─IndexRangeScan 1.00 cop[tikv] table:t, index:b(b) range:[1,1], keep order:false", + "└─TableRowIDScan(Probe) 1.54 cop[tikv] table:t keep order:false" + ], + "Warnings": null + }, + { + "SQL": "desc format='brief' select /*+ use_index_merge(t) */ * from t where (a=1 and length(b)=1) or (b=1 and length(a)=1)", + "Plan": [ + "IndexMerge 0.29 root ", + "├─IndexRangeScan(Build) 1.00 cop[tikv] table:t, index:a(a) range:[1,1], keep order:false", + "├─IndexRangeScan(Build) 1.00 cop[tikv] table:t, index:b(b) range:[1,1], keep order:false", + "└─Selection(Probe) 0.29 cop[tikv] or(and(eq(test.t.a, 1), eq(length(cast(test.t.b, var_string(20))), 1)), and(eq(test.t.b, 1), eq(length(cast(test.t.a, var_string(20))), 1)))", + " └─TableRowIDScan 1.90 cop[tikv] table:t keep order:false" + ], + "Warnings": null + } + ] + }, + { + "Name": "TestLimitIndexLookUpKeepOrder", + "Cases": [ + { + "SQL": "desc format = 'brief' select * from t where a = 1 and b > 2 and b < 10 and d = 10 order by b,c limit 10", + "Plan": [ + "Limit 0.00 root offset:0, count:10", + "└─Projection 0.00 root test.t.a, test.t.b, test.t.c, test.t.d", + " └─IndexLookUp 0.00 root ", + " ├─IndexRangeScan(Build) 2.50 cop[tikv] table:t, index:idx(a, b, c) range:(1 2,1 10), keep order:true, stats:pseudo", + " └─Selection(Probe) 0.00 cop[tikv] eq(test.t.d, 10)", + " └─TableRowIDScan 2.50 cop[tikv] table:t keep order:false, stats:pseudo" + ] + }, + { + "SQL": "desc format = 'brief' select * from t where a = 1 and b > 2 and b < 10 and d = 10 order by b desc, c desc limit 10", + "Plan": [ + "Limit 0.00 root offset:0, count:10", + "└─Projection 0.00 root test.t.a, test.t.b, test.t.c, test.t.d", + " └─IndexLookUp 0.00 root ", + " ├─IndexRangeScan(Build) 2.50 cop[tikv] table:t, index:idx(a, b, c) range:(1 2,1 10), keep order:true, desc, stats:pseudo", + " └─Selection(Probe) 0.00 cop[tikv] eq(test.t.d, 10)", + " └─TableRowIDScan 2.50 cop[tikv] table:t keep order:false, stats:pseudo" + ] +>>>>>>> fb676b769... Revert "planner: donot prune all columns for Projection (#24024)" (#24180) } ] } diff --git a/planner/core/testdata/integration_suite_out.json b/planner/core/testdata/integration_suite_out.json index 652832586f3db..82ce208ee08b2 100644 --- a/planner/core/testdata/integration_suite_out.json +++ b/planner/core/testdata/integration_suite_out.json @@ -1481,5 +1481,62 @@ ] } ] +<<<<<<< HEAD +======= + }, + { + "Name": "TestMultiColMaxOneRow", + "Cases": [ + { + "SQL": "select (select c from t2 where t2.a = t1.a and t2.b = 1) from t1", + "Plan": [ + "HashJoin 10000.00 root left outer join, equal:[eq(test.t1.a, test.t2.a)]", + "├─TableReader(Build) 10.00 root data:Selection", + "│ └─Selection 10.00 cop[tikv] eq(test.t2.b, 1)", + "│ └─TableFullScan 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo", + "└─TableReader(Probe) 10000.00 root data:TableFullScan", + " └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo" + ] + }, + { + "SQL": "select (select c from t2 where t2.a = t1.a and (t2.b = 1 or t2.b = 2)) from t1", + "Plan": [ + "Projection 10000.00 root test.t2.c", + "└─Apply 10000.00 root CARTESIAN left outer join", + " ├─TableReader(Build) 10000.00 root data:TableFullScan", + " │ └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo", + " └─MaxOneRow(Probe) 1.00 root ", + " └─IndexLookUp 0.02 root ", + " ├─Selection(Build) 0.02 cop[tikv] or(eq(test.t2.b, 1), eq(test.t2.b, 2))", + " │ └─IndexRangeScan 10.00 cop[tikv] table:t2, index:PRIMARY(a, b) range: decided by [eq(test.t2.a, test.t1.a)], keep order:false, stats:pseudo", + " └─TableRowIDScan(Probe) 0.02 cop[tikv] table:t2 keep order:false, stats:pseudo" + ] + } + ] + }, + { + "Name": "TestIssue24095", + "Cases": [ + { + "SQL": "select count(*) from t join (select t.id, t.value v1 from t join t t1 on t.id = t1.id order by t.value limit 1) v on v.id = t.id and v.v1 = t.value;", + "Plan": [ + "StreamAgg 1.00 root funcs:count(1)->Column#10", + "└─HashJoin 1.00 root inner join, equal:[eq(test.t.id, test.t.id) eq(test.t.value, test.t.value)]", + " ├─Selection(Build) 0.80 root not(isnull(test.t.id)), not(isnull(test.t.value))", + " │ └─TopN 1.00 root test.t.value, offset:0, count:1", + " │ └─HashJoin 12487.50 root inner join, equal:[eq(test.t.id, test.t.id)]", + " │ ├─TableReader(Build) 9990.00 root data:Selection", + " │ │ └─Selection 9990.00 cop[tikv] not(isnull(test.t.id))", + " │ │ └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo", + " │ └─TableReader(Probe) 9990.00 root data:Selection", + " │ └─Selection 9990.00 cop[tikv] not(isnull(test.t.id))", + " │ └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo", + " └─TableReader(Probe) 9980.01 root data:Selection", + " └─Selection 9980.01 cop[tikv] not(isnull(test.t.id)), not(isnull(test.t.value))", + " └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo" + ] + } + ] +>>>>>>> fb676b769... Revert "planner: donot prune all columns for Projection (#24024)" (#24180) } ]