From 428577024bb12ae64ed97bb53564450390752b1b Mon Sep 17 00:00:00 2001 From: obdev Date: Wed, 30 Nov 2022 09:08:10 +0000 Subject: [PATCH] enable prune unstable path for table use default statistics --- src/sql/optimizer/ob_join_order.cpp | 3 +- .../r/mysql/default_statistic.result | 112 +++++++++--------- .../r/mysql/skyline_basic_mysql.result | 30 ++--- .../mysql/transformer_predicate_deduce.result | 15 +-- 4 files changed, 80 insertions(+), 80 deletions(-) diff --git a/src/sql/optimizer/ob_join_order.cpp b/src/sql/optimizer/ob_join_order.cpp index 621e4bc88..34db7cb1a 100644 --- a/src/sql/optimizer/ob_join_order.cpp +++ b/src/sql/optimizer/ob_join_order.cpp @@ -5792,8 +5792,7 @@ int ObJoinOrder::pruning_unstable_access_path(BaseTableOptInfo *table_opt_info, OB_ISNULL(session_info = get_plan()->get_optimizer_context().get_session_info())) { ret = OB_ERR_UNEXPECTED; LOG_WARN("unexpected null", K(ret), K(access_paths.count()), K(get_plan()), K(session_info)); - } else if (access_paths.count() <= 1 || - OB_DEFAULT_STAT_EST == table_meta_info_.cost_est_type_) { + } else if (access_paths.count() <= 1) { /* do not pruning access path */ } else if (OB_FAIL(try_pruning_base_table_access_path(access_paths, unstable_index_id))) { LOG_WARN("failed to pruning base table access path", K(ret)); diff --git a/tools/deploy/mysql_test/test_suite/optimizer/r/mysql/default_statistic.result b/tools/deploy/mysql_test/test_suite/optimizer/r/mysql/default_statistic.result index 9402c5b7b..50c885c5a 100644 --- a/tools/deploy/mysql_test/test_suite/optimizer/r/mysql/default_statistic.result +++ b/tools/deploy/mysql_test/test_suite/optimizer/r/mysql/default_statistic.result @@ -37,107 +37,107 @@ Outputs & filters: explain select * from t1 where c1 = 1; Query Plan -=================================== -|ID|OPERATOR |NAME|EST. ROWS|COST| ------------------------------------ -|0 |TABLE SCAN|t1 |1 |2 | -=================================== +===================================== +|ID|OPERATOR |NAME |EST. ROWS|COST| +------------------------------------- +|0 |TABLE SCAN|t1(k1)|1 |5 | +===================================== Outputs & filters: ------------------------------------- - 0 - output([t1.c1], [t1.c2], [t1.c3], [t1.c4], [t1.c5], [t1.c6], [t1.c7], [t1.c8], [t1.c9], [t1.c10]), filter([t1.c1 = 1]), rowset=256, - access([t1.c1], [t1.c2], [t1.c3], [t1.c4], [t1.c5], [t1.c6], [t1.c7], [t1.c8], [t1.c9], [t1.c10]), partitions(p0) + 0 - output([t1.c1], [t1.c2], [t1.c3], [t1.c4], [t1.c5], [t1.c6], [t1.c7], [t1.c8], [t1.c9], [t1.c10]), filter(nil), rowset=256, + access([t1.__pk_increment], [t1.c1], [t1.c2], [t1.c3], [t1.c4], [t1.c5], [t1.c6], [t1.c7], [t1.c8], [t1.c9], [t1.c10]), partitions(p0) explain select * from t1 where c1 < 1; Query Plan -=================================== -|ID|OPERATOR |NAME|EST. ROWS|COST| ------------------------------------ -|0 |TABLE SCAN|t1 |1 |2 | -=================================== +===================================== +|ID|OPERATOR |NAME |EST. ROWS|COST| +------------------------------------- +|0 |TABLE SCAN|t1(k1)|1 |5 | +===================================== Outputs & filters: ------------------------------------- - 0 - output([t1.c1], [t1.c2], [t1.c3], [t1.c4], [t1.c5], [t1.c6], [t1.c7], [t1.c8], [t1.c9], [t1.c10]), filter([t1.c1 < 1]), rowset=256, - access([t1.c1], [t1.c2], [t1.c3], [t1.c4], [t1.c5], [t1.c6], [t1.c7], [t1.c8], [t1.c9], [t1.c10]), partitions(p0) + 0 - output([t1.c1], [t1.c2], [t1.c3], [t1.c4], [t1.c5], [t1.c6], [t1.c7], [t1.c8], [t1.c9], [t1.c10]), filter(nil), rowset=256, + access([t1.__pk_increment], [t1.c1], [t1.c2], [t1.c3], [t1.c4], [t1.c5], [t1.c6], [t1.c7], [t1.c8], [t1.c9], [t1.c10]), partitions(p0) explain select * from t1 where c1 > 1; Query Plan -=================================== -|ID|OPERATOR |NAME|EST. ROWS|COST| ------------------------------------ -|0 |TABLE SCAN|t1 |1 |2 | -=================================== +===================================== +|ID|OPERATOR |NAME |EST. ROWS|COST| +------------------------------------- +|0 |TABLE SCAN|t1(k1)|1 |5 | +===================================== Outputs & filters: ------------------------------------- - 0 - output([t1.c1], [t1.c2], [t1.c3], [t1.c4], [t1.c5], [t1.c6], [t1.c7], [t1.c8], [t1.c9], [t1.c10]), filter([t1.c1 > 1]), rowset=256, - access([t1.c1], [t1.c2], [t1.c3], [t1.c4], [t1.c5], [t1.c6], [t1.c7], [t1.c8], [t1.c9], [t1.c10]), partitions(p0) + 0 - output([t1.c1], [t1.c2], [t1.c3], [t1.c4], [t1.c5], [t1.c6], [t1.c7], [t1.c8], [t1.c9], [t1.c10]), filter(nil), rowset=256, + access([t1.__pk_increment], [t1.c1], [t1.c2], [t1.c3], [t1.c4], [t1.c5], [t1.c6], [t1.c7], [t1.c8], [t1.c9], [t1.c10]), partitions(p0) explain select * from t1 where c1 > 1 and c1 < 10; Query Plan -=================================== -|ID|OPERATOR |NAME|EST. ROWS|COST| ------------------------------------ -|0 |TABLE SCAN|t1 |1 |2 | -=================================== +===================================== +|ID|OPERATOR |NAME |EST. ROWS|COST| +------------------------------------- +|0 |TABLE SCAN|t1(k1)|1 |5 | +===================================== Outputs & filters: ------------------------------------- - 0 - output([t1.c1], [t1.c2], [t1.c3], [t1.c4], [t1.c5], [t1.c6], [t1.c7], [t1.c8], [t1.c9], [t1.c10]), filter([t1.c1 > 1], [t1.c1 < 10]), rowset=256, - access([t1.c1], [t1.c2], [t1.c3], [t1.c4], [t1.c5], [t1.c6], [t1.c7], [t1.c8], [t1.c9], [t1.c10]), partitions(p0) + 0 - output([t1.c1], [t1.c2], [t1.c3], [t1.c4], [t1.c5], [t1.c6], [t1.c7], [t1.c8], [t1.c9], [t1.c10]), filter(nil), rowset=256, + access([t1.__pk_increment], [t1.c1], [t1.c2], [t1.c3], [t1.c4], [t1.c5], [t1.c6], [t1.c7], [t1.c8], [t1.c9], [t1.c10]), partitions(p0) explain select * from t1 where c1 = 1 and c2 < 1; Query Plan -=================================== -|ID|OPERATOR |NAME|EST. ROWS|COST| ------------------------------------ -|0 |TABLE SCAN|t1 |1 |2 | -=================================== +===================================== +|ID|OPERATOR |NAME |EST. ROWS|COST| +------------------------------------- +|0 |TABLE SCAN|t1(k2)|1 |5 | +===================================== Outputs & filters: ------------------------------------- - 0 - output([t1.c1], [t1.c2], [t1.c3], [t1.c4], [t1.c5], [t1.c6], [t1.c7], [t1.c8], [t1.c9], [t1.c10]), filter([t1.c2 < 1], [t1.c1 = 1]), rowset=256, - access([t1.c1], [t1.c2], [t1.c3], [t1.c4], [t1.c5], [t1.c6], [t1.c7], [t1.c8], [t1.c9], [t1.c10]), partitions(p0) + 0 - output([t1.c1], [t1.c2], [t1.c3], [t1.c4], [t1.c5], [t1.c6], [t1.c7], [t1.c8], [t1.c9], [t1.c10]), filter(nil), rowset=256, + access([t1.__pk_increment], [t1.c1], [t1.c2], [t1.c3], [t1.c4], [t1.c5], [t1.c6], [t1.c7], [t1.c8], [t1.c9], [t1.c10]), partitions(p0) explain select * from t1 where c1 = 1 and c2 = 1; Query Plan -=================================== -|ID|OPERATOR |NAME|EST. ROWS|COST| ------------------------------------ -|0 |TABLE SCAN|t1 |1 |2 | -=================================== +===================================== +|ID|OPERATOR |NAME |EST. ROWS|COST| +------------------------------------- +|0 |TABLE SCAN|t1(k2)|1 |5 | +===================================== Outputs & filters: ------------------------------------- - 0 - output([t1.c1], [t1.c2], [t1.c3], [t1.c4], [t1.c5], [t1.c6], [t1.c7], [t1.c8], [t1.c9], [t1.c10]), filter([t1.c1 = 1], [t1.c2 = 1]), rowset=256, - access([t1.c1], [t1.c2], [t1.c3], [t1.c4], [t1.c5], [t1.c6], [t1.c7], [t1.c8], [t1.c9], [t1.c10]), partitions(p0) + 0 - output([t1.c1], [t1.c2], [t1.c3], [t1.c4], [t1.c5], [t1.c6], [t1.c7], [t1.c8], [t1.c9], [t1.c10]), filter(nil), rowset=256, + access([t1.__pk_increment], [t1.c1], [t1.c2], [t1.c3], [t1.c4], [t1.c5], [t1.c6], [t1.c7], [t1.c8], [t1.c9], [t1.c10]), partitions(p0) explain select * from t1 where c1 = 1 and c2 = 1 and c3 < 1; Query Plan -=================================== -|ID|OPERATOR |NAME|EST. ROWS|COST| ------------------------------------ -|0 |TABLE SCAN|t1 |1 |2 | -=================================== +===================================== +|ID|OPERATOR |NAME |EST. ROWS|COST| +------------------------------------- +|0 |TABLE SCAN|t1(k3)|1 |5 | +===================================== Outputs & filters: ------------------------------------- - 0 - output([t1.c1], [t1.c2], [t1.c3], [t1.c4], [t1.c5], [t1.c6], [t1.c7], [t1.c8], [t1.c9], [t1.c10]), filter([t1.c3 < 1], [t1.c1 = 1], [t1.c2 = 1]), rowset=256, - access([t1.c1], [t1.c2], [t1.c3], [t1.c4], [t1.c5], [t1.c6], [t1.c7], [t1.c8], [t1.c9], [t1.c10]), partitions(p0) + 0 - output([t1.c1], [t1.c2], [t1.c3], [t1.c4], [t1.c5], [t1.c6], [t1.c7], [t1.c8], [t1.c9], [t1.c10]), filter(nil), rowset=256, + access([t1.__pk_increment], [t1.c1], [t1.c2], [t1.c3], [t1.c4], [t1.c5], [t1.c6], [t1.c7], [t1.c8], [t1.c9], [t1.c10]), partitions(p0) explain select * from t1 where c1 = 1 and c2 = 1 and c3 = 1; Query Plan -=================================== -|ID|OPERATOR |NAME|EST. ROWS|COST| ------------------------------------ -|0 |TABLE SCAN|t1 |1 |3 | -=================================== +===================================== +|ID|OPERATOR |NAME |EST. ROWS|COST| +------------------------------------- +|0 |TABLE SCAN|t1(k3)|1 |5 | +===================================== Outputs & filters: ------------------------------------- - 0 - output([t1.c1], [t1.c2], [t1.c3], [t1.c4], [t1.c5], [t1.c6], [t1.c7], [t1.c8], [t1.c9], [t1.c10]), filter([t1.c1 = 1], [t1.c2 = 1], [t1.c3 = 1]), rowset=256, - access([t1.c1], [t1.c2], [t1.c3], [t1.c4], [t1.c5], [t1.c6], [t1.c7], [t1.c8], [t1.c9], [t1.c10]), partitions(p0) + 0 - output([t1.c1], [t1.c2], [t1.c3], [t1.c4], [t1.c5], [t1.c6], [t1.c7], [t1.c8], [t1.c9], [t1.c10]), filter(nil), rowset=256, + access([t1.__pk_increment], [t1.c1], [t1.c2], [t1.c3], [t1.c4], [t1.c5], [t1.c6], [t1.c7], [t1.c8], [t1.c9], [t1.c10]), partitions(p0) explain select count(*) from t2; Query Plan diff --git a/tools/deploy/mysql_test/test_suite/skyline/r/mysql/skyline_basic_mysql.result b/tools/deploy/mysql_test/test_suite/skyline/r/mysql/skyline_basic_mysql.result index 70e0f0cf1..c73f69551 100644 --- a/tools/deploy/mysql_test/test_suite/skyline/r/mysql/skyline_basic_mysql.result +++ b/tools/deploy/mysql_test/test_suite/skyline/r/mysql/skyline_basic_mysql.result @@ -247,13 +247,13 @@ Outputs & filters: explain select distinct(c),b, d from t1 where b > 200 limit 100; Query Plan -======================================= -|ID|OPERATOR |NAME|EST. ROWS|COST| ---------------------------------------- -|0 |LIMIT | |1 |3 | -|1 | HASH DISTINCT| |1 |3 | -|2 | TABLE SCAN |t1 |1 |2 | -======================================= +================================================ +|ID|OPERATOR |NAME |EST. ROWS|COST| +------------------------------------------------ +|0 |LIMIT | |1 |5 | +|1 | HASH DISTINCT| |1 |5 | +|2 | TABLE SCAN |t1(idx_c_a_b)|1 |5 | +================================================ Outputs & filters: ------------------------------------- @@ -261,7 +261,7 @@ Outputs & filters: 1 - output([t1.c], [t1.b], [t1.d]), filter(nil), rowset=256, distinct([t1.c], [t1.b], [t1.d]) 2 - output([t1.b], [t1.c], [t1.d]), filter([t1.b > 200]), rowset=256, - access([t1.b], [t1.c], [t1.d]), partitions(p0) + access([t1.pk1], [t1.b], [t1.c], [t1.d]), partitions(p0) explain select b from t1 order by b; Query Plan @@ -2966,16 +2966,16 @@ Outputs & filters: explain select * from t7 where a >= 0 and a <= 5 and b = 1; Query Plan -=================================== -|ID|OPERATOR |NAME|EST. ROWS|COST| ------------------------------------ -|0 |TABLE SCAN|t7 |1 |2 | -=================================== +===================================== +|ID|OPERATOR |NAME |EST. ROWS|COST| +------------------------------------- +|0 |TABLE SCAN|t7(k1)|1 |5 | +===================================== Outputs & filters: ------------------------------------- - 0 - output([t7.a], [t7.b], [t7.c], [t7.d], [t7.e], [t7.f]), filter([t7.a >= 0], [t7.a <= 5], [t7.b = 1]), rowset=256, - access([t7.a], [t7.b], [t7.c], [t7.d], [t7.e], [t7.f]), partitions(p0) + 0 - output([t7.a], [t7.b], [t7.c], [t7.d], [t7.e], [t7.f]), filter([t7.b = 1]), rowset=256, + access([t7.__pk_increment], [t7.a], [t7.b], [t7.c], [t7.d], [t7.e], [t7.f]), partitions(p0) explain select * from t8 where e = 1 order by b; Query Plan diff --git a/tools/deploy/mysql_test/test_suite/transformer/r/mysql/transformer_predicate_deduce.result b/tools/deploy/mysql_test/test_suite/transformer/r/mysql/transformer_predicate_deduce.result index 84ce644e2..47bf13943 100644 --- a/tools/deploy/mysql_test/test_suite/transformer/r/mysql/transformer_predicate_deduce.result +++ b/tools/deploy/mysql_test/test_suite/transformer/r/mysql/transformer_predicate_deduce.result @@ -3521,9 +3521,9 @@ Query Plan ================================================== |ID|OPERATOR |NAME |EST. ROWS|COST| -------------------------------------------------- -|0 |SCALAR GROUP BY | |1 |4 | -|1 | NESTED-LOOP JOIN | |1 |4 | -|2 | TABLE SCAN |A |1 |2 | +|0 |SCALAR GROUP BY | |1 |6 | +|1 | NESTED-LOOP JOIN | |1 |6 | +|2 | TABLE SCAN |A(c1)|1 |5 | |3 | DISTRIBUTED TABLE SCAN|B(c2)|1 |16 | ================================================== @@ -3533,10 +3533,11 @@ Outputs & filters: group(nil), agg_func([T_FUN_COUNT(*)]) 1 - output(nil), filter(nil), rowset=256, conds(nil), nl_params_([A.c1]), batch_join=true - 2 - output([A.c1]), filter([A.c1 >= 5630905], [A.c1 < 5631105], [A.c2 < 5631105], [A.c1 = A.c2]), rowset=256, - access([A.c1], [A.c2]), partitions(p0), - is_index_back=false, filter_before_indexback[false,false,false,false], - range_key([A.__pk_increment]), range(MIN ; MAX)always true + 2 - output([A.c1]), filter([A.c2 < 5631105], [A.c1 = A.c2]), rowset=256, + access([A.__pk_increment], [A.c1], [A.c2]), partitions(p0), + is_index_back=true, filter_before_indexback[false,false], + range_key([A.c1], [A.__pk_increment]), range(5630905,MIN ; 5631105,MIN), + range_cond([A.c1 >= 5630905], [A.c1 < 5631105]) 3 - output(nil), filter(nil), rowset=256, access([GROUP_ID]), partitions(p0), is_index_back=false,