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

Function best_access_path

sql/sql_select.cc:8755–10117  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

8753
8754
8755void
8756best_access_path(JOIN *join,
8757 JOIN_TAB *s,
8758 table_map remaining_tables,
8759 const POSITION *join_positions,
8760 uint idx,
8761 bool disable_jbuf,
8762 double record_count,
8763 POSITION *pos,
8764 POSITION *loose_scan_pos)
8765{
8766 THD *thd= join->thd;
8767 uint use_cond_selectivity=
8768 thd->variables.optimizer_use_condition_selectivity;
8769 TABLE *table= s->table;
8770 handler *file= table->file;
8771 my_bool found_constraint= 0;
8772 /*
8773 key_dependent is 0 if all key parts could be used or if there was an
8774 EQ_REF table found (which uses all key parts). In other words, we cannot
8775 find a better key for the table even if remaining_tables is reduced.
8776 Otherwise it's a bitmap of tables that could improve key usage.
8777 */
8778 table_map key_dependent= 0;
8779 ALL_READ_COST tmp;
8780 ha_rows rec;
8781 MY_BITMAP *eq_join_set= &s->table->eq_join_set;
8782 KEYUSE *hj_start_key= 0;
8783 table_map spl_pd_boundary= 0;
8784 Loose_scan_opt loose_scan_opt;
8785 struct best_plan best;
8786 Json_writer_object trace_wrapper(thd, "best_access_path");
8787 DBUG_ENTER("best_access_path");
8788
8789 /*
8790 Assume that there is at least one accepted row from previous table
8791 combinations.
8792 This fixes a problem when the selectivity for the preceding table
8793 combinations becomes so high that record_count becomes << 1.0,
8794 which makes the cost for the current table so low that it does not
8795 matter when calculating the best plans.
8796 */
8797 set_if_bigger(record_count, 1.0);
8798
8799 best.cost= DBL_MAX;
8800 best.records= DBL_MAX;
8801 best.records_read= DBL_MAX;
8802 best.records_out= MY_MIN(table->stat_records() * table->cond_selectivity,
8803 table->opt_range_condition_rows);
8804 best.identical_keys= 0;
8805 best.filter= 0;
8806 best.key= 0;
8807 best.max_key_part= 0;
8808 best.type= JT_UNKNOWN;
8809 best.forced_index= MAX_KEY;
8810 best.found_ref= 0;
8811 best.ref_depends_map= 0;
8812 best.refills= 0;

Callers 5

optimize_straight_joinFunction · 0.85
get_costs_for_tablesFunction · 0.85
check_qepMethod · 0.85

Calls 15

is_hash_join_key_noFunction · 0.85
bitmap_set_bitFunction · 0.85
max_part_bitFunction · 0.85
cost_for_index_readFunction · 0.85
bitmap_is_clear_allFunction · 0.85
optimizer_flagFunction · 0.85
hash_join_fanoutFunction · 0.85
use_found_constraintFunction · 0.85
cache_record_lengthFunction · 0.85
COST_MULTFunction · 0.85
COST_ADDFunction · 0.85

Tested by

no test coverage detected