Note:
This topic has been translated from a Chinese forum by GPT and might contain errors.Original topic: tidb-6.1.0 执行计划不走tiflash
[TiDB Usage Environment] Test Environment
[TiDB Version] tidb-v6.1.0
[Encountered Problem] Aggregate SQL does not use TiFlash
[Problem Phenomenon and Impact]
Cluster Topology:
Synchronize a table to TiFlash
SQL Execution Plan
MySQL [test]> explain select lesson_id, group_level_8, sum(col_1), sum(col_2), sum(col_3), sum(col_4), sum(col_5), sum(col_6), sum(col_7), sum(col_8), sum(col_9), sum(col_10), sum(col_11), sum(col_12), sum(col_13), sum(col_14), sum(col_15), sum(col_16), sum(col_17), sum(col_18), sum(col_19), sum(col_20), sum(col_21), sum(col_22), sum(col_23), sum(col_24), sum(col_25), sum(col_26), sum(col_27), sum(col_28), sum(col_29), sum(col_30), sum(col_31), sum(col_32), sum(col_33), sum(col_34), sum(col_35), sum(col_36), sum(col_37), sum(col_38), sum(col_39), sum(col_40) from tbldatasopcal_500r_200c where index1 in (1,2,3) and index2 in (1,2,3) and index4 in (1,2,3) and index5 in (1,2,3) group by lesson_id, group_level_8 limit 1\G
*************************** 1. row ***************************
id: Projection_8
estRows: 1.00
task: root
access object:
operator info: test.tbldatasopcal_500r_200c.lesson_id, test.tbldatasopcal_500r_200c.group_level_8, Column#202, Column#203, Column#204, Column#205, Column#206, Column#207, Column#208, Column#209, Column#210, Column#211, Column#212, Column#213, Column#214, Column#215, Column#216, Column#217, Column#218, Column#219, Column#220, Column#221, Column#222, Column#223, Column#224, Column#225, Column#226, Column#227, Column#228, Column#229, Column#230, Column#231, Column#232, Column#233, Column#234, Column#235, Column#236, Column#237, Column#238, Column#239, Column#240, Column#241
*************************** 2. row ***************************
id: └─Limit_11
estRows: 1.00
task: root
access object:
operator info: offset:0, count:1
*************************** 3. row ***************************
id: └─HashAgg_37
estRows: 1.00
task: root
access object:
operator info: group by:test.tbldatasopcal_500r_200c.group_level_8, test.tbldatasopcal_500r_200c.lesson_id, funcs:sum(Column#288)->Column#202, funcs:sum(Column#289)->Column#203, funcs:sum(Column#290)->Column#204, funcs:sum(Column#291)->Column#205, funcs:sum(Column#292)->Column#206, funcs:sum(Column#293)->Column#207, funcs:sum(Column#294)->Column#208, funcs:sum(Column#295)->Column#209, funcs:sum(Column#296)->Column#210, funcs:sum(Column#297)->Column#211, funcs:sum(Column#298)->Column#212, funcs:sum(Column#299)->Column#213, funcs:sum(Column#300)->Column#214, funcs:sum(Column#301)->Column#215, funcs:sum(Column#302)->Column#216, funcs:sum(Column#303)->Column#217, funcs:sum(Column#304)->Column#218, funcs:sum(Column#305)->Column#219, funcs:sum(Column#306)->Column#220, funcs:sum(Column#307)->Column#221, funcs:sum(Column#308)->Column#222, funcs:sum(Column#309)->Column#223, funcs:sum(Column#310)->Column#224, funcs:sum(Column#311)->Column#225, funcs:sum(Column#312)->Column#226, funcs:sum(Column#313)->Column#227, funcs:sum(Column#314)->Column#228, funcs:sum(Column#315)->Column#229, funcs:sum(Column#316)->Column#230, funcs:sum(Column#317)->Column#231, funcs:sum(Column#318)->Column#232, funcs:sum(Column#319)->Column#233, funcs:sum(Column#320)->Column#234, funcs:sum(Column#321)->Column#235, funcs:sum(Column#322)->Column#236, funcs:sum(Column#323)->Column#237, funcs:sum(Column#324)->Column#238, funcs:sum(Column#325)->Column#239, funcs:sum(Column#326)->Column#240, funcs:sum(Column#327)->Column#241, funcs:firstrow(test.tbldatasopcal_500r_200c.lesson_id)->test.tbldatasopcal_500r_200c.lesson_id, funcs:firstrow(test.tbldatasopcal_500r_200c.group_level_8)->test.tbldatasopcal_500r_200c.group_level_8
*************************** 4. row ***************************
id: └─IndexLookUp_38
estRows: 1.00
task: root
access object:
operator info:
*************************** 5. row ***************************
id: ├─IndexRangeScan_25(Build)
estRows: 749928.18
task: cop[tikv]
access object: table:tbldatasopcal_500r_200c, index:index1_idx(index1)
operator info: range:[1,1], [2,2], [3,3], keep order:false
*************************** 6. row ***************************
id: └─HashAgg_14(Probe)
estRows: 1.00
task: cop[tikv]
access object:
operator info: group by:test.tbldatasopcal_500r_200c.group_level_8, test.tbldatasopcal_500r_200c.lesson_id, funcs:sum(test.tbldatasopcal_500r_200c.col_1)->Column#288, funcs:sum(test.tbldatasopcal_500r_200c.col_2)->Column#289, funcs:sum(test.tbldatasopcal_500r_200c.col_3)->Column#290, funcs:sum(test.tbldatasopcal_500r_200c.col_4)->Column#291, funcs:sum(test.tbldatasopcal_500r_200c.col_5)->Column#292, funcs:sum(test.tbldatasopcal_500r_200c.col_6)->Column#293, funcs:sum(test.tbldatasopcal_500r_200c.col_7)->Column#294, funcs:sum(test.tbldatasopcal_500r_200c.col_8)->Column#295, funcs:sum(test.tbldatasopcal_500r_200c.col_9)->Column#296, funcs:sum(test.tbldatasopcal_500r_200c.col_10)->Column#297, funcs:sum(test.tbldatasopcal_500r_200c.col_11)->Column#298, funcs:sum(test.tbldatasopcal_500r_200c.col_12)->Column#299, funcs:sum(test.tbldatasopcal_500r_200c.col_13)->Column#300, funcs:sum(test.tbldatasopcal_500r_200c.col_14)->Column#301, funcs:sum(test.tbldatasopcal_500r_200c.col_15)->Column#302, funcs:sum(test.tbldatasopcal_500r_200c.col_16)->Column#303, funcs:sum(test.tbldatasopcal_500r_200c.col_17)->Column#304, funcs:sum(test.tbldatasopcal_500r_200c.col_18)->Column#305, funcs:sum(test.tbldatasopcal_500r_200c.col_19)->Column#306, funcs:sum(test.tbldatasopcal_500r_200c.col_20)->Column#307, funcs:sum(test.tbldatasopcal_500r_200c.col_21)->Column#308, funcs:sum(test.tbldatasopcal_500r_200c.col_22)->Column#309, funcs:sum(test.tbldatasopcal_500r_200c.col_23)->Column#310, funcs:sum(test.tbldatasopcal_500r_200c.col_24)->Column#311, funcs:sum(test.tbldatasopcal_500r_200c.col_25)->Column#312, funcs:sum(test.tbldatasopcal_500r_200c.col_26)->Column#313, funcs:sum(test.tbldatasopcal_500r_200c.col_27)->Column#314, funcs:sum(test.tbldatasopcal_500r_200c.col_28)->Column#315, funcs:sum(test.tbldatasopcal_500r_200c.col_29)->Column#316, funcs:sum(test.tbldatasopcal_500r_200c.col_30)->Column#317, funcs:sum(test.tbldatasopcal_500r_200c.col_31)->Column#318, funcs:sum(test.tbldatasopcal_500r_200c.col_32)->Column#319, funcs:sum(test.tbldatasopcal_500r_200c.col_33)->Column#320, funcs:sum(test.tbldatasopcal_500r_200c.col_34)->Column#321, funcs:sum(test.tbldatasopcal_500r_200c.col_35)->Column#322, funcs:sum(test.tbldatasopcal_500r_200c.col_36)->Column#323, funcs:sum(test.tbldatasopcal_500r_200c.col_37)->Column#324, funcs:sum(test.tbldatasopcal_500r_200c.col_38)->Column#325, funcs:sum(test.tbldatasopcal_500r_200c.col_39)->Column#326, funcs:sum(test.tbldatasopcal_500r_200c.col_40)->Column#327
*************************** 7. row ***************************
id: └─Selection_27
estRows: 312767.14
task: cop[tikv]
access object:
operator info: in(test.tbldatasopcal_500r_200c.index2, 1, 2, 3), in(test.tbldatasopcal_500r_200c.index4, 1, 2, 3), in(test.tbldatasopcal_500r_200c.index5, 1, 2, 3)
*************************** 8. row ***************************
id: └─TableRowIDScan_26
estRows: 749928.18
task: cop[tikv]
access object: table:tbldatasopcal_500r_200c
operator info: keep order:false
8 rows in set (0.01 sec)
This cluster was upgraded from 5.4.2 to 6.1.0.
Because during the stress test in 5.4, when the concurrency of the above SQL reached more than 10, the time consumption increased significantly and the CPU consumption was very high. There were also the following logs:
However, after upgrading to 6.1.0, the SQL does not automatically route to TiFlash.