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

Function table_multi_eq_cond_selectivity

sql/sql_select.cc:11132–11239  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

11130*/
11131
11132static
11133double table_multi_eq_cond_selectivity(JOIN *join, uint idx, JOIN_TAB *s,
11134 table_map rem_tables, uint keyparts,
11135 uint16 *ref_keyuse_steps)
11136{
11137 double sel= 1.0;
11138 COND_EQUAL *cond_equal= join->cond_equal;
11139
11140 if (!cond_equal || !cond_equal->current_level.elements || !s->keyuse)
11141 return sel;
11142
11143 Item_equal *item_equal;
11144 List_iterator_fast<Item_equal> it(cond_equal->current_level);
11145 TABLE *table= s->table;
11146 table_map table_bit= table->map;
11147 POSITION *pos= &join->positions[idx];
11148
11149 while ((item_equal= it++))
11150 {
11151 /*
11152 Check whether we need to take into account the selectivity of
11153 multiple equality item_equal. If this is the case multiply
11154 the current value of sel by this selectivity
11155 */
11156 table_map used_tables= item_equal->used_tables();
11157 if (!(used_tables & table_bit))
11158 continue;
11159 if (item_equal->get_const())
11160 continue;
11161
11162 bool adjust_sel= FALSE;
11163 Item_equal_fields_iterator fi(*item_equal);
11164 while((fi++) && !adjust_sel)
11165 {
11166 Field *fld= fi.get_curr_field();
11167 if (fld->table->map != table_bit)
11168 continue;
11169 if (pos->key == 0)
11170 adjust_sel= TRUE;
11171 else
11172 {
11173 uint i;
11174 KEYUSE *keyuse= pos->key;
11175 uint key= keyuse->key;
11176 for (i= 0; i < keyparts; i++)
11177 {
11178 if (i > 0)
11179 keyuse+= ref_keyuse_steps[i-1];
11180 uint fldno;
11181 if (is_hash_join_key_no(key))
11182 fldno= keyuse->keypart;
11183 else
11184 fldno= table->key_info[key].key_part[i].fieldnr - 1;
11185 if (fld->field_index == fldno)
11186 break;
11187 }
11188 keyuse= pos->key;
11189

Callers 1

Calls 10

is_hash_join_key_noFunction · 0.85
get_column_avg_frequencyFunction · 0.85
get_constMethod · 0.80
get_curr_fieldMethod · 0.80
stat_recordsMethod · 0.80
used_tablesMethod · 0.45
typeMethod · 0.45
real_itemMethod · 0.45
containsMethod · 0.45
rewindMethod · 0.45

Tested by

no test coverage detected