From 742afd8eaeccb3531fa350b31445e8397dab7848 Mon Sep 17 00:00:00 2001 From: Sergey Petrunya Date: Tue, 19 Jan 2010 01:32:23 +0300 Subject: [PATCH] Subquery optimizations: Backport into 5.3: - Enable semi-join handling in the join cache code --- sql/sql_join_cache.cc | 9 +-------- sql/sql_select.h | 1 + 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/sql/sql_join_cache.cc b/sql/sql_join_cache.cc index 9bbfd4f3964..79234e6f7bf 100644 --- a/sql/sql_join_cache.cc +++ b/sql/sql_join_cache.cc @@ -354,7 +354,6 @@ void JOIN_CACHE:: create_remaining_fields(bool all_read_fields) ©_ptr); /* SemiJoinDuplicateElimination: allocate space for rowid if needed */ -/* !!! NB igor: Enable the code in the comment after backporting the SJ code if (tab->keep_current_rowid) { copy->str= table->file->ref; @@ -366,7 +365,6 @@ void JOIN_CACHE:: create_remaining_fields(bool all_read_fields) data_field_count++; copy++; } -*/ } } @@ -1778,10 +1776,8 @@ enum_nested_loop_state JOIN_CACHE_BNL::join_matching_records(bool skip_last) info= &join_tab->read_record; do { -/* !!! NB igor: Enable the code in the comment after backporting the SJ code if (join_tab->keep_current_rowid) join_tab->table->file->position(join_tab->table->record[0]); -*/ if (join->thd->killed) { @@ -1913,10 +1909,9 @@ enum_nested_loop_state JOIN_CACHE::generate_full_extensions(uchar *rec_ptr) if (check_match(rec_ptr)) { int res= 0; -/* !!! NB igor: Enable the code in the comment after backporting the SJ code + if (!join_tab->check_weed_out_table || !(res= do_sj_dups_weedout(join->thd, join_tab->check_weed_out_table))) -*/ { set_curr_rec_link(rec_ptr); rc= (join_tab->next_select)(join, join_tab+1, 0); @@ -2291,10 +2286,8 @@ enum_nested_loop_state JOIN_CACHE_BKA::join_matching_records(bool skip_last) rc= NESTED_LOOP_KILLED; goto finish; } -/* !!!NB igor: Enable the statement in the comment after backporting the SJ code if (join_tab->keep_current_rowid) join_tab->table->file->position(join_tab->table->record[0]); -*/ /* If only the first match is needed and it has been already found for the associated partial join record then the returned candidate diff --git a/sql/sql_select.h b/sql/sql_select.h index 0c9cec6092b..9fbf9621575 100644 --- a/sql/sql_select.h +++ b/sql/sql_select.h @@ -1197,6 +1197,7 @@ enum_nested_loop_state sub_select(JOIN *join,JOIN_TAB *join_tab, bool end_of_records); enum_nested_loop_state sub_select_sjm(JOIN *join, JOIN_TAB *join_tab, bool end_of_records); +int do_sj_dups_weedout(THD *thd, SJ_TMP_TABLE *sjtbl); /** Information about a position of table within a join order. Used in join