MCPcopy Create free account
hub / github.com/MariaDB/server / optimize_wo_join_buffering

Function optimize_wo_join_buffering

sql/sql_select.cc:20663–20769  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

20661*/
20662
20663void optimize_wo_join_buffering(JOIN *join, uint first_tab, uint last_tab,
20664 table_map last_remaining_tables,
20665 bool first_alt, uint no_jbuf_before,
20666 double *outer_rec_count, double *reopt_cost)
20667{
20668 double cost, rec_count;
20669 table_map reopt_remaining_tables= last_remaining_tables;
20670 uint i;
20671 THD *thd= join->thd;
20672 Json_writer_temp_disable trace_wo_join_buffering(thd);
20673
20674 if (first_tab > join->const_tables)
20675 {
20676 cost= join->positions[first_tab - 1].prefix_cost;
20677 rec_count= join->positions[first_tab - 1].prefix_record_count;
20678 }
20679 else
20680 {
20681 cost= 0.0;
20682 rec_count= 1;
20683 }
20684
20685 *outer_rec_count= rec_count;
20686 for (i= first_tab; i <= last_tab; i++)
20687 reopt_remaining_tables |= join->positions[i].table->table->map;
20688
20689 /*
20690 best_access_path() optimization depends on the value of
20691 join->cur_sj_inner_tables. Our goal in this function is to do a
20692 re-optimization with disabled join buffering, but no other changes.
20693 In order to achieve this, cur_sj_inner_tables needs have the same
20694 value it had during the original invocations of best_access_path.
20695
20696 We know that this function, optimize_wo_join_buffering() is called to
20697 re-optimize semi-join join order range, which allows to conclude that
20698 the "original" value of cur_sj_inner_tables was 0.
20699 */
20700 table_map save_cur_sj_inner_tables= join->cur_sj_inner_tables;
20701 join->cur_sj_inner_tables= 0;
20702
20703 double inner_fanout= 1.0;
20704
20705 for (i= first_tab; i <= last_tab; i++)
20706 {
20707 JOIN_TAB *rs= join->positions[i].table;
20708 POSITION pos, loose_scan_pos;
20709
20710 if ((i == first_tab && first_alt) || join->positions[i].use_join_buffer)
20711 {
20712 /* Find the best access method that would not use join buffering */
20713 best_access_path(join, rs, reopt_remaining_tables,
20714 join->positions, i,
20715 TRUE, rec_count,
20716 &pos, &loose_scan_pos);
20717 if ((i == first_tab && first_alt))
20718 pos= loose_scan_pos;
20719 }
20720 else

Callers 1

check_qepMethod · 0.85

Calls 4

best_access_pathFunction · 0.85
COST_ADDFunction · 0.85
COST_MULTFunction · 0.85

Tested by

no test coverage detected