1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-07 00:04:31 +03:00

Small semi-join optimization improvement:

- if we're considering FirstMatch access with one inner table, and 
  @@optimizer_switch has semijoin_with_cache flag, calculate costs
  as if we used join cache (because we will be able to do so)
This commit is contained in:
Sergey Petrunya
2011-12-08 04:22:38 +04:00
parent 8e96081764
commit ae480437ce
10 changed files with 56 additions and 49 deletions

View File

@@ -2617,13 +2617,27 @@ bool Firstmatch_picker::check_qep(JOIN *join,
!(firstmatch_need_tables & remaining_tables))
{
/*
Got a complete FirstMatch range.
Calculate correct costs and fanout
Got a complete FirstMatch range. Calculate correct costs and fanout
*/
optimize_wo_join_buffering(join, first_firstmatch_table, idx,
remaining_tables, FALSE, idx,
record_count,
read_time);
if (idx == first_firstmatch_table &&
optimizer_flag(join->thd, OPTIMIZER_SWITCH_SEMIJOIN_WITH_CACHE))
{
/*
An important special case: only one inner table, and @@optimizer_switch
allows join buffering.
- read_time is the same (i.e. FirstMatch doesn't add any cost
- remove fanout added by the last table
*/
*record_count /= join->positions[idx].records_read;
}
else
{
optimize_wo_join_buffering(join, first_firstmatch_table, idx,
remaining_tables, FALSE, idx,
record_count,
read_time);
}
/*
We ought to save the alternate POSITIONs produced by
optimize_wo_join_buffering but the problem is that providing save