refine NLJ、SPF`s rescan cost

This commit is contained in:
zzg19950727 2023-02-27 11:13:59 +00:00 committed by ob-robot
parent 6272a505cb
commit a77a3dc6cf
4 changed files with 37 additions and 23 deletions

View File

@ -3181,6 +3181,18 @@ int ObJoinOrder::get_excluded_condition_exprs(ObIArray<ObRawExpr *> &excluded_co
return ret;
}
double ObJoinOrder::calc_single_parallel_rows(double rows, int64_t parallel)
{
double ret = rows;
if (rows < parallel) {
parallel = rows;
//at least one parallel
parallel = parallel < 1 ? 1: parallel;
}
ret = rows / parallel;
return ret;
}
int ObJoinOrder::compute_const_exprs_for_subquery(uint64_t table_id,
ObLogicalOperator *root)
{
@ -5457,7 +5469,7 @@ int JoinPath::cost_nest_loop_join(double left_output_rows,
right_part_cnt = right_path_->get_sharding()->get_part_cnt();
}
if (DistAlgo::DIST_BC2HOST_NONE == join_dist_algo_) {
left_rows = left_rows * server_cnt_ / in_parallel;
left_rows = ObJoinOrder::calc_single_parallel_rows(left_rows, in_parallel/server_cnt_);
right_cost = right_cost * right_out_parallel / server_cnt_;
right_rows /= server_cnt_;
} else if (DistAlgo::DIST_BROADCAST_NONE == join_dist_algo_ ||
@ -5465,11 +5477,11 @@ int JoinPath::cost_nest_loop_join(double left_output_rows,
right_rows /= in_parallel;
} else if (DistAlgo::DIST_NONE_BROADCAST == join_dist_algo_ ||
DistAlgo::DIST_NONE_ALL == join_dist_algo_) {
left_rows /= in_parallel;
left_rows = ObJoinOrder::calc_single_parallel_rows(left_rows, in_parallel);
} else if (DistAlgo::DIST_PULL_TO_LOCAL == join_dist_algo_) {
/* do nothing */
} else {
left_rows /= in_parallel;
left_rows = ObJoinOrder::calc_single_parallel_rows(left_rows, in_parallel);
right_rows /= right_part_cnt;
right_cost = right_cost * right_out_parallel / right_part_cnt;
}

View File

@ -2207,6 +2207,7 @@ struct NullAwareAntiJoinInfo {
inline uint64_t get_total_path_num() const { return total_path_num_; }
int get_join_output_exprs(ObIArray<ObRawExpr *> &output_exprs);
int get_excluded_condition_exprs(ObIArray<ObRawExpr *> &excluded_conditions);
static double calc_single_parallel_rows(double rows, int64_t parallel);
private:
static int check_and_remove_is_null_qual(ObLogPlan *plan,
const ObJoinType join_type,

View File

@ -300,7 +300,8 @@ int ObLogSubPlanFilter::get_children_cost_info(double &first_child_refine_card,
ret = OB_ERR_UNEXPECTED;
LOG_WARN("get unexpected null", K(ret), K(i));
} else {
double child_card = (i == 0) ? first_child_refine_card / parallel : child->get_card();
double first_child_card = ObJoinOrder::calc_single_parallel_rows(first_child_refine_card, parallel);
double child_card = (i == 0) ? first_child_card : child->get_card();
ObBasicCostInfo info(child_card, child->get_cost(), child->get_width(), child->is_exchange_allocated());
if (OB_FAIL(children_cost_info.push_back(info))) {
LOG_WARN("push back child's cost info failed", K(ret));

View File

@ -962,11 +962,11 @@ Query Plan
==============================================================
|ID|OPERATOR |NAME |EST.ROWS|EST.TIME(us)|
--------------------------------------------------------------
|0 |PX COORDINATOR MERGE SORT | |1 |7 |
|1 | EXCHANGE OUT DISTR |:EX10000|1 |7 |
|2 | SORT | |1 |7 |
|3 | PX PARTITION ITERATOR | |1 |7 |
|4 | SUBPLAN FILTER | |1 |7 |
|0 |PX COORDINATOR MERGE SORT | |1 |9 |
|1 | EXCHANGE OUT DISTR |:EX10000|1 |9 |
|2 | SORT | |1 |9 |
|3 | PX PARTITION ITERATOR | |1 |9 |
|4 | SUBPLAN FILTER | |1 |9 |
|5 | TABLE SCAN |t1 |1 |5 |
|6 | TABLE SCAN |t2 |1 |5 |
==============================================================
@ -1007,11 +1007,11 @@ Query Plan
==============================================================
|ID|OPERATOR |NAME |EST.ROWS|EST.TIME(us)|
--------------------------------------------------------------
|0 |PX COORDINATOR MERGE SORT | |1 |9 |
|1 | EXCHANGE OUT DISTR |:EX10000|1 |9 |
|2 | SORT | |1 |9 |
|3 | PX PARTITION ITERATOR | |1 |9 |
|4 | SUBPLAN FILTER | |1 |9 |
|0 |PX COORDINATOR MERGE SORT | |1 |13 |
|1 | EXCHANGE OUT DISTR |:EX10000|1 |13 |
|2 | SORT | |1 |13 |
|3 | PX PARTITION ITERATOR | |1 |13 |
|4 | SUBPLAN FILTER | |1 |13 |
|5 | TABLE SCAN |t1 |1 |5 |
|6 | TABLE SCAN |t2 |1 |5 |
|7 | TABLE SCAN |t2 |1 |5 |
@ -1120,10 +1120,10 @@ Query Plan
==================================================================
|ID|OPERATOR |NAME |EST.ROWS|EST.TIME(us)|
------------------------------------------------------------------
|0 |PX COORDINATOR MERGE SORT | |1 |7 |
|1 | EXCHANGE OUT DISTR |:EX10001|1 |7 |
|2 | SORT | |1 |7 |
|3 | SUBPLAN FILTER | |1 |7 |
|0 |PX COORDINATOR MERGE SORT | |1 |10 |
|1 | EXCHANGE OUT DISTR |:EX10001|1 |10 |
|2 | SORT | |1 |9 |
|3 | SUBPLAN FILTER | |1 |9 |
|4 | EXCHANGE IN DISTR | |1 |5 |
|5 | EXCHANGE OUT DISTR (PKEY)|:EX10000|1 |5 |
|6 | PX BLOCK ITERATOR | |1 |5 |
@ -1408,10 +1408,10 @@ Query Plan
==================================================================
|ID|OPERATOR |NAME |EST.ROWS|EST.TIME(us)|
------------------------------------------------------------------
|0 |PX COORDINATOR MERGE SORT | |1 |9 |
|1 | EXCHANGE OUT DISTR |:EX10001|1 |9 |
|2 | SORT | |1 |9 |
|3 | SUBPLAN FILTER | |1 |9 |
|0 |PX COORDINATOR MERGE SORT | |1 |12 |
|1 | EXCHANGE OUT DISTR |:EX10001|1 |12 |
|2 | SORT | |1 |12 |
|3 | SUBPLAN FILTER | |1 |12 |
|4 | EXCHANGE IN DISTR | |1 |5 |
|5 | EXCHANGE OUT DISTR (PKEY)|:EX10000|1 |5 |
|6 | PX BLOCK ITERATOR | |1 |5 |
@ -1582,7 +1582,7 @@ Query Plan
|6 | MERGE GROUP BY | |1 |12 |
|7 | PX COORDINATOR | |2 |12 |
|8 | EXCHANGE OUT DISTR |:EX20002|2 |12 |
|9 | MERGE GROUP BY | |2 |11 |
|9 | MERGE GROUP BY | |2 |12 |
|10| NESTED-LOOP JOIN CARTESIAN | |1 |11 |
|11| NESTED-LOOP JOIN CARTESIAN | |1 |8 |
|12| PX BLOCK ITERATOR | |1 |5 |