Non partitioned tables optimization check all tables first

This commit is contained in:
obdev
2022-12-29 15:38:15 +00:00
committed by ob-robot
parent 124965e385
commit 9822def517

View File

@ -2774,18 +2774,27 @@ int ObSql::code_generate(
} // for end } // for end
} }
} }
// get tablet id and partition id for non partition tables
if (OB_SUCC(ret)) { if (OB_SUCC(ret)) {
bool skip_non_partition_optimized = false;
for (int64_t i = 0; OB_SUCC(ret) && i < tbl_part_infos.count(); i++) { for (int64_t i = 0; OB_SUCC(ret) && i < tbl_part_infos.count(); i++) {
ObTableLocation &tl = tbl_part_infos.at(i)->get_table_location(); ObTableLocation &tl = tbl_part_infos.at(i)->get_table_location();
if (tl.is_partitioned() || is_virtual_table(tl.get_loc_meta().ref_table_id_)) { if (tl.is_partitioned() || is_virtual_table(tl.get_loc_meta().ref_table_id_)) {
continue; skip_non_partition_optimized = true;
} else if (OB_FAIL(tl.calc_not_partitioned_table_ids(result.get_exec_context()))) { break;
}
}
if (OB_SUCC(ret) && !skip_non_partition_optimized) {
for (int64_t i = 0; OB_SUCC(ret) && i < tbl_part_infos.count(); i++) {
ObTableLocation &tl = tbl_part_infos.at(i)->get_table_location();
if (OB_FAIL(tl.calc_not_partitioned_table_ids(result.get_exec_context()))) {
LOG_WARN("failed to calc not partitioned table ids", K(ret)); LOG_WARN("failed to calc not partitioned table ids", K(ret));
} else { } else {
tl.set_is_non_partition_optimized(true); tl.set_is_non_partition_optimized(true);
} }
} }
} }
}
// set table location for phy_plan // set table location for phy_plan
if (OB_SUCC(ret)) { if (OB_SUCC(ret)) {
if (OB_FAIL(phy_plan->set_table_locations(tbl_part_infos, *sql_ctx.schema_guard_))) { if (OB_FAIL(phy_plan->set_table_locations(tbl_part_infos, *sql_ctx.schema_guard_))) {