[ { "Name": "TestPlanGeneration", "Cases": [ { "SQL": "explain explore select max(b) from t where a=1", "Plan": [ [ "StreamAgg 1.00 root funcs:max(test.t.b)->Column#5", "└─TopN 1.00 root test.t.b:desc, offset:0, count:1", " └─TableReader 1.00 root data:TopN", " └─TopN 1.00 cop[tikv] test.t.b:desc, offset:0, count:1", " └─Selection 9.99 cop[tikv] eq(test.t.a, 1), not(isnull(test.t.b))", " └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo" ], [ "StreamAgg 1.00 root funcs:max(test.t.b)->Column#5", "└─TopN 1.00 root test.t.b:desc, offset:0, count:1", " └─IndexLookUp 1.00 root ", " ├─IndexRangeScan(Build) 10.00 cop[tikv] table:t, index:a(a) range:[1,1], keep order:false, stats:pseudo", " └─TopN(Probe) 1.00 cop[tikv] test.t.b:desc, offset:0, count:1", " └─Selection 9.99 cop[tikv] not(isnull(test.t.b))", " └─TableRowIDScan 10.00 cop[tikv] table:t keep order:false, stats:pseudo" ], [ "HashAgg 1.00 root funcs:max(test.t.b)->Column#5", "└─TopN 1.00 root test.t.b:desc, offset:0, count:1", " └─TableReader 1.00 root data:TopN", " └─TopN 1.00 cop[tikv] test.t.b:desc, offset:0, count:1", " └─Selection 9.99 cop[tikv] eq(test.t.a, 1), not(isnull(test.t.b))", " └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo" ], [ "HashAgg 1.00 root funcs:max(test.t.b)->Column#5", "└─TopN 1.00 root test.t.b:desc, offset:0, count:1", " └─IndexLookUp 1.00 root ", " ├─IndexRangeScan(Build) 10.00 cop[tikv] table:t, index:a(a) range:[1,1], keep order:false, stats:pseudo", " └─TopN(Probe) 1.00 cop[tikv] test.t.b:desc, offset:0, count:1", " └─Selection 9.99 cop[tikv] not(isnull(test.t.b))", " └─TableRowIDScan 10.00 cop[tikv] table:t keep order:false, stats:pseudo" ] ] }, { "SQL": "explain explore select * from t where a=1", "Plan": [ [ "TableReader 10.00 root data:Selection", "└─Selection 10.00 cop[tikv] eq(test.t.a, 1)", " └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo" ], [ "IndexLookUp 10.00 root ", "├─IndexRangeScan(Build) 10.00 cop[tikv] table:t, index:a(a) range:[1,1], keep order:false, stats:pseudo", "└─TableRowIDScan(Probe) 10.00 cop[tikv] table:t keep order:false, stats:pseudo" ] ] }, { "SQL": "explain explore select * from t where b=1", "Plan": [ [ "TableReader 10.00 root data:Selection", "└─Selection 10.00 cop[tikv] eq(test.t.b, 1)", " └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo" ] ] }, { "SQL": "explain explore select * from t1, t2, t3", "Plan": [ [ "HashJoin 1000000000000.00 root CARTESIAN inner join", "├─HashJoin(Probe) 100000000.00 root CARTESIAN inner join", "│ ├─TableReader(Probe) 10000.00 root data:TableFullScan", "│ │ └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo", "│ └─TableReader(Build) 10000.00 root data:TableFullScan", "│ └─TableFullScan 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo", "└─TableReader(Build) 10000.00 root data:TableFullScan", " └─TableFullScan 10000.00 cop[tikv] table:t3 keep order:false, stats:pseudo" ] ] }, { "SQL": "explain explore select * from t1, t2 where t1.a=t2.a", "Plan": [ [ "MergeJoin 12487.50 root inner join, left key:test.t1.a, right key:test.t2.a", "├─Projection(Probe) 9990.00 root test.t1.a, test.t1.b, test.t1.c", "│ └─IndexLookUp 9990.00 root ", "│ ├─IndexFullScan(Build) 9990.00 cop[tikv] table:t1, index:a(a) keep order:true, stats:pseudo", "│ └─TableRowIDScan(Probe) 9990.00 cop[tikv] table:t1 keep order:false, stats:pseudo", "└─Projection(Build) 9990.00 root test.t2.a, test.t2.b, test.t2.c", " └─IndexLookUp 9990.00 root ", " ├─IndexFullScan(Build) 9990.00 cop[tikv] table:t2, index:a(a) keep order:true, stats:pseudo", " └─TableRowIDScan(Probe) 9990.00 cop[tikv] table:t2 keep order:false, stats:pseudo" ], [ "IndexHashJoin 12487.50 root inner join, inner:IndexLookUp, outer key:test.t1.a, inner key:test.t2.a, equal cond:eq(test.t1.a, test.t2.a)", "├─TableReader(Build) 9990.00 root data:Selection", "│ └─Selection 9990.00 cop[tikv] not(isnull(test.t1.a))", "│ └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo", "└─IndexLookUp(Probe) 12487.50 root ", " ├─Selection(Build) 12487.50 cop[tikv] not(isnull(test.t2.a))", " │ └─IndexRangeScan 12500.00 cop[tikv] table:t2, index:a(a) range: decided by [eq(test.t2.a, test.t1.a)], keep order:false, stats:pseudo", " └─TableRowIDScan(Probe) 12487.50 cop[tikv] table:t2 keep order:false, stats:pseudo" ], [ "HashJoin 12487.50 root inner join, equal:[eq(test.t1.a, test.t2.a)]", "├─TableReader(Probe) 9990.00 root data:Selection", "│ └─Selection 9990.00 cop[tikv] not(isnull(test.t1.a))", "│ └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo", "└─TableReader(Build) 9990.00 root data:Selection", " └─Selection 9990.00 cop[tikv] not(isnull(test.t2.a))", " └─TableFullScan 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo" ], [ "IndexHashJoin 12487.50 root inner join, inner:IndexLookUp, outer key:test.t1.a, inner key:test.t2.a, equal cond:eq(test.t1.a, test.t2.a)", "├─IndexLookUp(Build) 9990.00 root ", "│ ├─IndexFullScan(Build) 9990.00 cop[tikv] table:t1, index:a(a) keep order:false, stats:pseudo", "│ └─TableRowIDScan(Probe) 9990.00 cop[tikv] table:t1 keep order:false, stats:pseudo", "└─IndexLookUp(Probe) 12487.50 root ", " ├─Selection(Build) 12487.50 cop[tikv] not(isnull(test.t2.a))", " │ └─IndexRangeScan 12500.00 cop[tikv] table:t2, index:a(a) range: decided by [eq(test.t2.a, test.t1.a)], keep order:false, stats:pseudo", " └─TableRowIDScan(Probe) 12487.50 cop[tikv] table:t2 keep order:false, stats:pseudo" ] ] } ] }, { "Name": "TestRelevantOptVarsAndFixes", "Cases": [ { "Vars": "[tidb_opt_index_reader_cost_factor tidb_opt_index_scan_cost_factor tidb_opt_prefer_range_scan tidb_opt_table_full_scan_cost_factor tidb_opt_table_reader_cost_factor]", "Fixes": "[45132]" }, { "Vars": "[tidb_opt_index_reader_cost_factor tidb_opt_index_scan_cost_factor tidb_opt_prefer_range_scan]", "Fixes": "[52869]" }, { "Vars": "[tidb_opt_index_lookup_cost_factor tidb_opt_index_scan_cost_factor tidb_opt_prefer_range_scan tidb_opt_table_rowid_scan_cost_factor]", "Fixes": "[52869]" }, { "Vars": "[tidb_opt_index_lookup_cost_factor tidb_opt_index_scan_cost_factor tidb_opt_prefer_range_scan tidb_opt_table_full_scan_cost_factor tidb_opt_table_reader_cost_factor tidb_opt_table_rowid_scan_cost_factor]", "Fixes": "[45132 52869]" }, { "Vars": "[tidb_opt_index_reader_cost_factor tidb_opt_index_scan_cost_factor tidb_opt_prefer_range_scan]", "Fixes": "[52869]" }, { "Vars": "[tidb_opt_index_lookup_cost_factor tidb_opt_index_scan_cost_factor tidb_opt_prefer_range_scan tidb_opt_table_rowid_scan_cost_factor]", "Fixes": "[52869]" }, { "Vars": "[tidb_opt_hash_agg_cost_factor tidb_opt_index_reader_cost_factor tidb_opt_index_scan_cost_factor tidb_opt_ordering_index_selectivity_ratio tidb_opt_prefer_range_scan tidb_opt_stream_agg_cost_factor tidb_opt_topn_cost_factor]", "Fixes": "[52869]" }, { "Vars": "[tidb_opt_hash_agg_cost_factor tidb_opt_index_lookup_cost_factor tidb_opt_index_scan_cost_factor tidb_opt_prefer_range_scan tidb_opt_stream_agg_cost_factor tidb_opt_table_rowid_scan_cost_factor]", "Fixes": "[52869]" }, { "Vars": "[tidb_opt_index_lookup_cost_factor tidb_opt_index_scan_cost_factor tidb_opt_prefer_range_scan tidb_opt_sort_cost_factor tidb_opt_table_rowid_scan_cost_factor]", "Fixes": "[45132 52869]" }, { "Vars": "[tidb_opt_index_lookup_cost_factor tidb_opt_index_scan_cost_factor tidb_opt_prefer_range_scan tidb_opt_table_range_scan_cost_factor tidb_opt_table_rowid_scan_cost_factor tidb_opt_topn_cost_factor]", "Fixes": "[52869]" }, { "Vars": "[tidb_opt_hash_join_cost_factor tidb_opt_index_join_cost_factor tidb_opt_index_reader_cost_factor tidb_opt_index_scan_cost_factor tidb_opt_merge_join_cost_factor tidb_opt_ordering_index_selectivity_ratio tidb_opt_prefer_range_scan]", "Fixes": "[44855 45132 52869]" }, { "Vars": "[tidb_opt_hash_join_cost_factor tidb_opt_index_join_cost_factor tidb_opt_index_reader_cost_factor tidb_opt_index_scan_cost_factor tidb_opt_merge_join_cost_factor tidb_opt_ordering_index_selectivity_ratio tidb_opt_prefer_range_scan]", "Fixes": "[44855 45132 52869]" }, { "Vars": "[tidb_opt_hash_join_cost_factor tidb_opt_ordering_index_selectivity_ratio tidb_opt_prefer_range_scan tidb_opt_table_full_scan_cost_factor tidb_opt_table_reader_cost_factor]", "Fixes": "[52869]" } ] } ]