Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

优化并行执行的条件判断 #75

Merged
merged 6 commits into from
May 25, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 30 additions & 18 deletions sql/pq_condition.cc
Original file line number Diff line number Diff line change
Expand Up @@ -750,6 +750,28 @@ bool suite_for_parallel_query(SELECT_LEX_UNIT *unit) {
return true;
}

bool suite_for_parallel_query(TABLE_LIST *tbl_list) {
if (tbl_list->is_view()) {
return false;
}

// skip explicit table lock
if (tbl_list->lock_descriptor().type > TL_READ ||
current_thd->locking_clause) {
return false;
}

TABLE *tb = tbl_list->table;
if (tb != nullptr &&
(tb->s->tmp_table != NO_TMP_TABLE || // template table
tb->file->ht->db_type != DB_TYPE_INNODB || // Non-InnoDB table
tb->part_info || // partition table
tb->fulltext_searched)) { // fulltext match search
return false;
}
return true;
}

bool suite_for_parallel_query(SELECT_LEX *select) {
if (select->first_inner_unit() != nullptr || // nesting subquery, including view〝derived table〝subquery condition and so on.
select->outer_select() != nullptr || // nested subquery
Expand All @@ -761,27 +783,17 @@ bool suite_for_parallel_query(SELECT_LEX *select) {

for (TABLE_LIST *tbl_list = select->table_list.first; tbl_list != nullptr;
tbl_list = tbl_list->next_local) {
// skip view
if (tbl_list->is_view()) {
return false;
if (!suite_for_parallel_query(tbl_list)) {
return false;
}

// skip explicit table lock
if (tbl_list->lock_descriptor().type > TL_READ ||
current_thd->locking_clause) {
return false;
}

for (TABLE_LIST *tbl_list = select->leaf_tables; tbl_list != nullptr;
tbl_list = tbl_list->next_leaf) {
if (!suite_for_parallel_query(tbl_list)) {
return false;
}

TABLE *tb = tbl_list->table;
if (tb != nullptr &&
(tb->s->tmp_table != NO_TMP_TABLE || // template table
tb->file->ht->db_type != DB_TYPE_INNODB || // Non-InnoDB table
tb->part_info || // partition table
tb->fulltext_searched)) { // fulltext match search
return false;
}
}

return true;
}

Expand Down