diff options
author | Monty <monty@mariadb.org> | 2022-06-01 17:11:40 +0300 |
---|---|---|
committer | Sergei Golubchik <serg@mariadb.org> | 2022-06-18 15:23:13 +0200 |
commit | f85c65d3c1ee397a9cef6b2c9c3c65666f219a7b (patch) | |
tree | a20c7f1d5066462babab1c6507ea18bef444fdda | |
parent | d13a910fb354d358517e7f3e3c4528178469699a (diff) | |
download | mariadb-git-f85c65d3c1ee397a9cef6b2c9c3c65666f219a7b.tar.gz |
Remove unnecessary testing of join dependency when sorting tables
The dependency checking is not needed when using
best_extension_by_limited_search() as this function ensures
that we don't use tables that are depending on any of the remaning
tables.
-rw-r--r-- | sql/sql_select.cc | 25 |
1 files changed, 10 insertions, 15 deletions
diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 05da970dca7..0058ce668b1 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -8891,14 +8891,9 @@ join_tab_cmp(const void *dummy, const void* ptr1, const void* ptr2) if ((cmp= compare_embedding_subqueries(jt1, jt2)) != 0) return cmp; /* - After that, - take care about ordering imposed by LEFT JOIN constraints, - possible [eq]ref accesses, and numbers of matching records in the table. + After that do ordering according to numbers of + records in the table. */ - if (jt1->dependent & jt2->table->map) - return 1; - if (jt2->dependent & jt1->table->map) - return -1; if (jt1->found_records > jt2->found_records) return 1; if (jt1->found_records < jt2->found_records) @@ -8929,10 +8924,15 @@ join_tab_cmp_straight(const void *dummy, const void* ptr1, const void* ptr2) if ((cmp= compare_embedding_subqueries(jt1, jt2)) != 0) return cmp; + /* + We have to check dependency with straight_join as we don't reorder + later as we do for other plans in best_extension_by_limited_search(). + */ if (jt1->dependent & jt2->table->map) return 1; if (jt2->dependent & jt1->table->map) return -1; + return jt1 > jt2 ? 1 : (jt1 < jt2 ? -1 : 0); } @@ -8954,11 +8954,6 @@ join_tab_cmp_embedded_first(const void *emb, const void* ptr1, const void* ptr2 if (jt1->emb_sj_nest != emb_nest && jt2->emb_sj_nest == emb_nest) return 1; - if (jt1->dependent & jt2->table->map) - return 1; - if (jt2->dependent & jt1->table->map) - return -1; - if (jt1->found_records > jt2->found_records) return 1; if (jt1->found_records < jt2->found_records) @@ -9031,9 +9026,9 @@ determine_search_depth(JOIN *join) access method. The final optimal plan is stored in the array 'join->best_positions', and the corresponding cost in 'join->best_read'. - @param join pointer to the structure providing all context info for - the query - @param join_tables set of the tables in the query + @param join pointer to the structure providing all context info + for the query + @param remaining_tables set of the tables in the query @note This function can be applied to: |