Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

planner: projection don't new unnecessary column #13406

Merged
merged 11 commits into from
Nov 20, 2019
2 changes: 1 addition & 1 deletion cmd/explaintest/r/access_path_selection.result
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ StreamAgg_13 1.00 root funcs:max(Column#3)
└─TableScan_25 1.25 cop[tikv] table:access_path_selection, range:[-inf,+inf], keep order:true, desc, stats:pseudo
explain select count(1) from access_path_selection;
id count task operator info
StreamAgg_28 1.00 root funcs:count(Column#19)
StreamAgg_28 1.00 root funcs:count(Column#18)
└─TableReader_29 1.00 root data:StreamAgg_8
└─StreamAgg_8 1.00 cop[tikv] funcs:count(1)
└─TableScan_24 10000.00 cop[tikv] table:access_path_selection, range:[-inf,+inf], keep order:false, stats:pseudo
10 changes: 5 additions & 5 deletions cmd/explaintest/r/access_tiflash.result
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,31 @@ drop table if exists t, tt;
create table t(a int, b int, index ia(a));
desc select avg(a) from t;
id count task operator info
StreamAgg_20 1.00 root funcs:avg(Column#8, Column#9)
StreamAgg_20 1.00 root funcs:avg(Column#7, Column#8)
└─IndexReader_21 1.00 root index:StreamAgg_8
└─StreamAgg_8 1.00 cop[tikv] funcs:avg(Column#1)
└─IndexScan_19 10000.00 cop[tikv] table:t, index:a, range:[NULL,+inf], keep order:false, stats:pseudo
desc select /*+ read_from_storage(tiflash[t]) */ avg(a) from t;
id count task operator info
StreamAgg_16 1.00 root funcs:avg(Column#8, Column#9)
StreamAgg_16 1.00 root funcs:avg(Column#7, Column#8)
└─TableReader_17 1.00 root data:StreamAgg_8
└─StreamAgg_8 1.00 cop[tiflash] funcs:count(Column#1), sum(Column#1)
└─TableScan_15 10000.00 cop[tiflash] table:t, range:[-inf,+inf], keep order:false, stats:pseudo
desc select /*+ read_from_storage(tiflash[t]) */ sum(a) from t;
id count task operator info
StreamAgg_16 1.00 root funcs:sum(Column#7)
StreamAgg_16 1.00 root funcs:sum(Column#6)
└─TableReader_17 1.00 root data:StreamAgg_8
└─StreamAgg_8 1.00 cop[tiflash] funcs:sum(Column#1)
└─TableScan_15 10000.00 cop[tiflash] table:t, range:[-inf,+inf], keep order:false, stats:pseudo
desc select /*+ read_from_storage(tiflash[t]) */ sum(a+1) from t;
id count task operator info
StreamAgg_16 1.00 root funcs:sum(Column#7)
StreamAgg_16 1.00 root funcs:sum(Column#6)
└─TableReader_17 1.00 root data:StreamAgg_8
└─StreamAgg_8 1.00 cop[tiflash] funcs:sum(plus(Column#1, 1))
└─TableScan_15 10000.00 cop[tiflash] table:t, range:[-inf,+inf], keep order:false, stats:pseudo
desc select /*+ read_from_storage(tiflash[t]) */ sum(isnull(a)) from t;
id count task operator info
StreamAgg_16 1.00 root funcs:sum(Column#7)
StreamAgg_16 1.00 root funcs:sum(Column#6)
└─TableReader_17 1.00 root data:StreamAgg_8
└─StreamAgg_8 1.00 cop[tiflash] funcs:sum(isnull(Column#1))
└─TableScan_15 10000.00 cop[tiflash] table:t, range:[-inf,+inf], keep order:false, stats:pseudo
Expand Down
4 changes: 2 additions & 2 deletions cmd/explaintest/r/explain.result
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ set session tidb_hashagg_partial_concurrency = 1;
set session tidb_hashagg_final_concurrency = 1;
explain select group_concat(a) from t group by id;
id count task operator info
StreamAgg_8 8000.00 root group by:Column#7, funcs:group_concat(Column#6, ",")
StreamAgg_8 8000.00 root group by:Column#6, funcs:group_concat(Column#5, ",")
└─Projection_18 10000.00 root cast(Column#2), Column#1
└─TableReader_15 10000.00 root data:TableScan_14
└─TableScan_14 10000.00 cop[tikv] table:t, range:[-inf,+inf], keep order:true, stats:pseudo
explain select group_concat(a, b) from t group by id;
id count task operator info
StreamAgg_8 8000.00 root group by:Column#8, funcs:group_concat(Column#6, Column#7, ",")
StreamAgg_8 8000.00 root group by:Column#7, funcs:group_concat(Column#5, Column#6, ",")
└─Projection_18 10000.00 root cast(Column#2), cast(Column#3), Column#1
└─TableReader_15 10000.00 root data:TableScan_14
└─TableScan_14 10000.00 cop[tikv] table:t, range:[-inf,+inf], keep order:true, stats:pseudo
Expand Down
8 changes: 4 additions & 4 deletions cmd/explaintest/r/explain_complex.result
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ explain SELECT `ds`, `p1`, `p2`, `p3`, `p4`, `p5`, `p6_md5`, `p7_md5`, count(dic
id count task operator info
Projection_7 53.00 root Column#7, Column#11, Column#12, Column#13, Column#14, Column#15, Column#16, Column#17, Column#21
└─Sort_8 53.00 root Column#8:desc
└─HashAgg_16 53.00 root group by:Column#52, Column#53, Column#54, Column#55, Column#56, Column#57, Column#58, Column#59, funcs:count(Column#42), firstrow(Column#52), firstrow(Column#44), firstrow(Column#53), firstrow(Column#54), firstrow(Column#55), firstrow(Column#56), firstrow(Column#57), firstrow(Column#58), firstrow(Column#59)
└─HashAgg_16 53.00 root group by:Column#42, Column#43, Column#44, Column#45, Column#46, Column#47, Column#48, Column#49, funcs:count(Column#32), firstrow(Column#42), firstrow(Column#34), firstrow(Column#43), firstrow(Column#44), firstrow(Column#45), firstrow(Column#46), firstrow(Column#47), firstrow(Column#48), firstrow(Column#49)
└─IndexLookUp_17 53.00 root
├─IndexScan_13 2650.00 cop[tikv] table:dt, index:cm, range:[1062,1062], [1086,1086], [1423,1423], [1424,1424], [1425,1425], [1426,1426], [1427,1427], [1428,1428], [1429,1429], [1430,1430], [1431,1431], [1432,1432], [1433,1433], [1434,1434], [1435,1435], [1436,1436], [1437,1437], [1438,1438], [1439,1439], [1440,1440], [1441,1441], [1442,1442], [1443,1443], [1444,1444], [1445,1445], [1446,1446], [1447,1447], [1448,1448], [1449,1449], [1450,1450], [1451,1451], [1452,1452], [1488,1488], [1489,1489], [1490,1490], [1491,1491], [1492,1492], [1493,1493], [1494,1494], [1495,1495], [1496,1496], [1497,1497], [1550,1550], [1551,1551], [1552,1552], [1553,1553], [1554,1554], [1555,1555], [1556,1556], [1557,1557], [1558,1558], [1559,1559], [1597,1597], [1598,1598], [1599,1599], [1600,1600], [1601,1601], [1602,1602], [1603,1603], [1604,1604], [1605,1605], [1606,1606], [1607,1607], [1608,1608], [1609,1609], [1610,1610], [1611,1611], [1612,1612], [1613,1613], [1614,1614], [1615,1615], [1616,1616], [1623,1623], [1624,1624], [1625,1625], [1626,1626], [1627,1627], [1628,1628], [1629,1629], [1630,1630], [1631,1631], [1632,1632], [1709,1709], [1719,1719], [1720,1720], [1843,1843], [2813,2813], [2814,2814], [2815,2815], [2816,2816], [2817,2817], [2818,2818], [2819,2819], [2820,2820], [2821,2821], [2822,2822], [2823,2823], [2824,2824], [2825,2825], [2826,2826], [2827,2827], [2828,2828], [2829,2829], [2830,2830], [2831,2831], [2832,2832], [2833,2833], [2834,2834], [2835,2835], [2836,2836], [2837,2837], [2838,2838], [2839,2839], [2840,2840], [2841,2841], [2842,2842], [2843,2843], [2844,2844], [2845,2845], [2846,2846], [2847,2847], [2848,2848], [2849,2849], [2850,2850], [2851,2851], [2852,2852], [2853,2853], [2854,2854], [2855,2855], [2856,2856], [2857,2857], [2858,2858], [2859,2859], [2860,2860], [2861,2861], [2862,2862], [2863,2863], [2864,2864], [2865,2865], [2866,2866], [2867,2867], [2868,2868], [2869,2869], [2870,2870], [2871,2871], [2872,2872], [3139,3139], [3140,3140], [3141,3141], [3142,3142], [3143,3143], [3144,3144], [3145,3145], [3146,3146], [3147,3147], [3148,3148], [3149,3149], [3150,3150], [3151,3151], [3152,3152], [3153,3153], [3154,3154], [3155,3155], [3156,3156], [3157,3157], [3158,3158], [3386,3386], [3387,3387], [3388,3388], [3389,3389], [3390,3390], [3391,3391], [3392,3392], [3393,3393], [3394,3394], [3395,3395], [3664,3664], [3665,3665], [3666,3666], [3667,3667], [3668,3668], [3670,3670], [3671,3671], [3672,3672], [3673,3673], [3674,3674], [3676,3676], [3677,3677], [3678,3678], [3679,3679], [3680,3680], [3681,3681], [3682,3682], [3683,3683], [3684,3684], [3685,3685], [3686,3686], [3687,3687], [3688,3688], [3689,3689], [3690,3690], [3691,3691], [3692,3692], [3693,3693], [3694,3694], [3695,3695], [3696,3696], [3697,3697], [3698,3698], [3699,3699], [3700,3700], [3701,3701], [3702,3702], [3703,3703], [3704,3704], [3705,3705], [3706,3706], [3707,3707], [3708,3708], [3709,3709], [3710,3710], [3711,3711], [3712,3712], [3713,3713], [3714,3714], [3715,3715], [3960,3960], [3961,3961], [3962,3962], [3963,3963], [3964,3964], [3965,3965], [3966,3966], [3967,3967], [3968,3968], [3978,3978], [3979,3979], [3980,3980], [3981,3981], [3982,3982], [3983,3983], [3984,3984], [3985,3985], [3986,3986], [3987,3987], [4208,4208], [4209,4209], [4210,4210], [4211,4211], [4212,4212], [4304,4304], [4305,4305], [4306,4306], [4307,4307], [4308,4308], [4866,4866], [4867,4867], [4868,4868], [4869,4869], [4870,4870], [4871,4871], [4872,4872], [4873,4873], [4874,4874], [4875,4875], keep order:false, stats:pseudo
└─HashAgg_11 53.00 cop[tikv] group by:Column#11, Column#12, Column#13, Column#14, Column#15, Column#16, Column#17, Column#7, funcs:count(Column#5), firstrow(Column#8)
Expand Down Expand Up @@ -179,8 +179,8 @@ CREATE TABLE `tbl_008` (`a` int, `b` int);
CREATE TABLE `tbl_009` (`a` int, `b` int);
explain select sum(a) from (select * from tbl_001 union all select * from tbl_002 union all select * from tbl_003 union all select * from tbl_004 union all select * from tbl_005 union all select * from tbl_006 union all select * from tbl_007 union all select * from tbl_008 union all select * from tbl_009) x group by b;
id count task operator info
HashAgg_34 72000.00 root group by:Column#51, funcs:sum(Column#50)
└─Projection_63 90000.00 root cast(Column#46), Column#47
HashAgg_34 72000.00 root group by:Column#32, funcs:sum(Column#31)
└─Projection_63 90000.00 root cast(Column#28), Column#29
└─Union_35 90000.00 root
├─TableReader_38 10000.00 root data:TableScan_37
│ └─TableScan_37 10000.00 cop[tikv] table:tbl_001, range:[-inf,+inf], keep order:false, stats:pseudo
Expand Down Expand Up @@ -242,7 +242,7 @@ UNIQUE KEY org_employee_position_pk (hotel_id,user_id,position_id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
explain SELECT d.id, d.ctx, d.name, d.left_value, d.right_value, d.depth, d.leader_id, d.status, d.created_on, d.updated_on FROM org_department AS d LEFT JOIN org_position AS p ON p.department_id = d.id AND p.status = 1000 LEFT JOIN org_employee_position AS ep ON ep.position_id = p.id AND ep.status = 1000 WHERE (d.ctx = 1 AND (ep.user_id = 62 OR d.id = 20 OR d.id = 20) AND d.status = 1000) GROUP BY d.id ORDER BY d.left_value;
id count task operator info
Sort_10 1.00 root Column#31:asc
Sort_10 1.00 root Column#4:asc
└─HashAgg_15 1.00 root group by:Column#1, funcs:firstrow(Column#1), firstrow(Column#2), firstrow(Column#3), firstrow(Column#4), firstrow(Column#5), firstrow(Column#6), firstrow(Column#7), firstrow(Column#8), firstrow(Column#9), firstrow(Column#10)
└─Selection_22 0.01 root or(eq(Column#22, 62), or(eq(Column#1, 20), eq(Column#1, 20)))
└─HashLeftJoin_24 0.02 root left outer join, inner:IndexMergeJoin_40 (REVERSED), equal:[eq(Column#11, Column#23)]
Expand Down
6 changes: 3 additions & 3 deletions cmd/explaintest/r/explain_complex_stats.result
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ explain SELECT ds, p1, p2, p3, p4, p5, p6_md5, p7_md5, count(dic) as install_dev
id count task operator info
Projection_7 21.53 root Column#7, Column#11, Column#12, Column#13, Column#14, Column#15, Column#16, Column#17, Column#21
└─Sort_8 21.53 root Column#8:desc
└─HashAgg_16 21.53 root group by:Column#52, Column#53, Column#54, Column#55, Column#56, Column#57, Column#58, Column#59, funcs:count(Column#42), firstrow(Column#52), firstrow(Column#44), firstrow(Column#53), firstrow(Column#54), firstrow(Column#55), firstrow(Column#56), firstrow(Column#57), firstrow(Column#58), firstrow(Column#59)
└─HashAgg_16 21.53 root group by:Column#42, Column#43, Column#44, Column#45, Column#46, Column#47, Column#48, Column#49, funcs:count(Column#32), firstrow(Column#42), firstrow(Column#34), firstrow(Column#43), firstrow(Column#44), firstrow(Column#45), firstrow(Column#46), firstrow(Column#47), firstrow(Column#48), firstrow(Column#49)
└─IndexLookUp_17 21.53 root
├─IndexScan_13 128.32 cop[tikv] table:dt, index:cm, range:[1062,1062], [1086,1086], [1423,1423], [1424,1424], [1425,1425], [1426,1426], [1427,1427], [1428,1428], [1429,1429], [1430,1430], [1431,1431], [1432,1432], [1433,1433], [1434,1434], [1435,1435], [1436,1436], [1437,1437], [1438,1438], [1439,1439], [1440,1440], [1441,1441], [1442,1442], [1443,1443], [1444,1444], [1445,1445], [1446,1446], [1447,1447], [1448,1448], [1449,1449], [1450,1450], [1451,1451], [1452,1452], [1488,1488], [1489,1489], [1490,1490], [1491,1491], [1492,1492], [1493,1493], [1494,1494], [1495,1495], [1496,1496], [1497,1497], [1550,1550], [1551,1551], [1552,1552], [1553,1553], [1554,1554], [1555,1555], [1556,1556], [1557,1557], [1558,1558], [1559,1559], [1597,1597], [1598,1598], [1599,1599], [1600,1600], [1601,1601], [1602,1602], [1603,1603], [1604,1604], [1605,1605], [1606,1606], [1607,1607], [1608,1608], [1609,1609], [1610,1610], [1611,1611], [1612,1612], [1613,1613], [1614,1614], [1615,1615], [1616,1616], [1623,1623], [1624,1624], [1625,1625], [1626,1626], [1627,1627], [1628,1628], [1629,1629], [1630,1630], [1631,1631], [1632,1632], [1709,1709], [1719,1719], [1720,1720], [1843,1843], [2813,2813], [2814,2814], [2815,2815], [2816,2816], [2817,2817], [2818,2818], [2819,2819], [2820,2820], [2821,2821], [2822,2822], [2823,2823], [2824,2824], [2825,2825], [2826,2826], [2827,2827], [2828,2828], [2829,2829], [2830,2830], [2831,2831], [2832,2832], [2833,2833], [2834,2834], [2835,2835], [2836,2836], [2837,2837], [2838,2838], [2839,2839], [2840,2840], [2841,2841], [2842,2842], [2843,2843], [2844,2844], [2845,2845], [2846,2846], [2847,2847], [2848,2848], [2849,2849], [2850,2850], [2851,2851], [2852,2852], [2853,2853], [2854,2854], [2855,2855], [2856,2856], [2857,2857], [2858,2858], [2859,2859], [2860,2860], [2861,2861], [2862,2862], [2863,2863], [2864,2864], [2865,2865], [2866,2866], [2867,2867], [2868,2868], [2869,2869], [2870,2870], [2871,2871], [2872,2872], [3139,3139], [3140,3140], [3141,3141], [3142,3142], [3143,3143], [3144,3144], [3145,3145], [3146,3146], [3147,3147], [3148,3148], [3149,3149], [3150,3150], [3151,3151], [3152,3152], [3153,3153], [3154,3154], [3155,3155], [3156,3156], [3157,3157], [3158,3158], [3386,3386], [3387,3387], [3388,3388], [3389,3389], [3390,3390], [3391,3391], [3392,3392], [3393,3393], [3394,3394], [3395,3395], [3664,3664], [3665,3665], [3666,3666], [3667,3667], [3668,3668], [3670,3670], [3671,3671], [3672,3672], [3673,3673], [3674,3674], [3676,3676], [3677,3677], [3678,3678], [3679,3679], [3680,3680], [3681,3681], [3682,3682], [3683,3683], [3684,3684], [3685,3685], [3686,3686], [3687,3687], [3688,3688], [3689,3689], [3690,3690], [3691,3691], [3692,3692], [3693,3693], [3694,3694], [3695,3695], [3696,3696], [3697,3697], [3698,3698], [3699,3699], [3700,3700], [3701,3701], [3702,3702], [3703,3703], [3704,3704], [3705,3705], [3706,3706], [3707,3707], [3708,3708], [3709,3709], [3710,3710], [3711,3711], [3712,3712], [3713,3713], [3714,3714], [3715,3715], [3960,3960], [3961,3961], [3962,3962], [3963,3963], [3964,3964], [3965,3965], [3966,3966], [3967,3967], [3968,3968], [3978,3978], [3979,3979], [3980,3980], [3981,3981], [3982,3982], [3983,3983], [3984,3984], [3985,3985], [3986,3986], [3987,3987], [4208,4208], [4209,4209], [4210,4210], [4211,4211], [4212,4212], [4304,4304], [4305,4305], [4306,4306], [4307,4307], [4308,4308], [4866,4866], [4867,4867], [4868,4868], [4869,4869], [4870,4870], [4871,4871], [4872,4872], [4873,4873], [4874,4874], [4875,4875], keep order:false
└─HashAgg_11 21.53 cop[tikv] group by:Column#11, Column#12, Column#13, Column#14, Column#15, Column#16, Column#17, Column#7, funcs:count(Column#5), firstrow(Column#8)
Expand Down Expand Up @@ -205,8 +205,8 @@ CREATE TABLE tbl_009 (a int, b int);
load stats 's/explain_complex_stats_tbl_009.json';
explain select sum(a) from (select * from tbl_001 union all select * from tbl_002 union all select * from tbl_003 union all select * from tbl_004 union all select * from tbl_005 union all select * from tbl_006 union all select * from tbl_007 union all select * from tbl_008 union all select * from tbl_009) x group by b;
id count task operator info
HashAgg_34 18000.00 root group by:Column#51, funcs:sum(Column#50)
└─Projection_63 18000.00 root cast(Column#46), Column#47
HashAgg_34 18000.00 root group by:Column#32, funcs:sum(Column#31)
└─Projection_63 18000.00 root cast(Column#28), Column#29
└─Union_35 18000.00 root
├─TableReader_38 2000.00 root data:TableScan_37
│ └─TableScan_37 2000.00 cop[tikv] table:tbl_001, range:[-inf,+inf], keep order:false
Expand Down
Loading