diff options
Diffstat (limited to 'sql')
-rw-r--r-- | sql/sql_select.cc | 21 | ||||
-rw-r--r-- | sql/sql_select.h | 13 |
2 files changed, 22 insertions, 12 deletions
diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 4b59b8086c7..c6c97764078 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -7635,8 +7635,7 @@ uint check_join_cache_usage(JOIN_TAB *tab, if (cache_level == 0 || i == join->const_tables || !prev_tab) return 0; - if (force_unlinked_cache && - (cache_level & JOIN_CACHE_INCREMENTAL_BIT)) + if (force_unlinked_cache && (cache_level%2 == 0)) cache_level--; if (options & SELECT_NO_JOIN_CACHE) @@ -7658,13 +7657,14 @@ uint check_join_cache_usage(JOIN_TAB *tab, /* Non-linked join buffers can't guarantee one match */ - if ((force_unlinked_cache || cache_level == 1) && - ((tab->is_inner_table_of_semi_join_with_first_match() && - !tab->is_single_inner_of_semi_join_with_first_match()) || - (tab->is_inner_table_of_outer_join() && - !tab->is_single_inner_of_outer_join()))) - goto no_join_cache; - + if (tab->is_nested_inner()) + { + if (force_unlinked_cache || cache_level == 1) + goto no_join_cache; + if (cache_level & 1) + cache_level--; + } + /* Don't use join buffering if we're dictated not to by no_jbuf_after (this ...) @@ -7757,9 +7757,6 @@ uint check_join_cache_usage(JOIN_TAB *tab, (cache_level <= 6 || no_hashed_cache)) goto no_join_cache; - if (prev_tab->cache && cache_level==7) - cache_level= 6; - if ((rows != HA_POS_ERROR) && !(flags & HA_MRR_USE_DEFAULT_IMPL)) { if (cache_level <= 6 || no_hashed_cache) diff --git a/sql/sql_select.h b/sql/sql_select.h index 1e57f487f69..ee6a58ed97e 100644 --- a/sql/sql_select.h +++ b/sql/sql_select.h @@ -359,6 +359,19 @@ typedef struct st_join_table { return (first_inner && first_inner->last_inner == this) || last_sj_inner_tab == this; } + /* + Check whether the table belongs to a nest of inner tables of an + outer join or to a nest of inner tables of a semi-join + */ + bool is_nested_inner() + { + if (first_inner && + (first_inner != first_inner->last_inner || first_inner->first_upper)) + return TRUE; + if (first_sj_inner_tab && first_sj_inner_tab != last_sj_inner_tab) + return TRUE; + return FALSE; + } struct st_join_table *get_first_inner_table() { if (first_inner) |