Commit 632f2307 authored by Alexander Barkov's avatar Alexander Barkov

MDEV-7950 Item_func::type() takes 0.26% in OLTP RO

Step#5: changing the function remove_eq_conds() into a virtual method in Item.
It removes 6 virtual calls for Item_func::type(), and adds only 2
virtual calls for Item***::remove_eq_conds().
parent fb3e9352
...@@ -1135,6 +1135,8 @@ class Item: public Type_std_attributes ...@@ -1135,6 +1135,8 @@ class Item: public Type_std_attributes
DBUG_ASSERT(!cond_equal_ref || !cond_equal_ref[0]); DBUG_ASSERT(!cond_equal_ref || !cond_equal_ref[0]);
return this; return this;
} }
virtual COND *remove_eq_conds(THD *thd, Item::cond_result *cond_value,
bool top_level);
/* /*
Checks whether the item is: Checks whether the item is:
- a simple equality (field=field_item or field=constant_item), or - a simple equality (field=field_item or field=constant_item), or
......
...@@ -409,6 +409,8 @@ class Item_bool_func2 :public Item_bool_func ...@@ -409,6 +409,8 @@ class Item_bool_func2 :public Item_bool_func
Item_bool_func::cleanup(); Item_bool_func::cleanup();
cmp.cleanup(); cmp.cleanup();
} }
COND *remove_eq_conds(THD *thd, Item::cond_result *cond_value,
bool top_level);
friend class Arg_comparator; friend class Arg_comparator;
}; };
...@@ -1467,6 +1469,8 @@ class Item_func_isnull :public Item_func_null_predicate ...@@ -1467,6 +1469,8 @@ class Item_func_isnull :public Item_func_null_predicate
const_item_cache= args[0]->const_item(); const_item_cache= args[0]->const_item();
} }
} }
COND *remove_eq_conds(THD *thd, Item::cond_result *cond_value,
bool top_level);
table_map not_null_tables() const { return 0; } table_map not_null_tables() const { return 0; }
Item *neg_transformer(THD *thd); Item *neg_transformer(THD *thd);
}; };
...@@ -1775,6 +1779,8 @@ class Item_cond :public Item_bool_func ...@@ -1775,6 +1779,8 @@ class Item_cond :public Item_bool_func
COND *build_equal_items(THD *thd, COND_EQUAL *inherited, COND *build_equal_items(THD *thd, COND_EQUAL *inherited,
bool link_item_fields, bool link_item_fields,
COND_EQUAL **cond_equal_ref); COND_EQUAL **cond_equal_ref);
COND *remove_eq_conds(THD *thd, Item::cond_result *cond_value,
bool top_level);
virtual void print(String *str, enum_query_type query_type); virtual void print(String *str, enum_query_type query_type);
void split_sum_func(THD *thd, Item **ref_pointer_array, List<Item> &fields); void split_sum_func(THD *thd, Item **ref_pointer_array, List<Item> &fields);
friend int setup_conds(THD *thd, TABLE_LIST *tables, TABLE_LIST *leaves, friend int setup_conds(THD *thd, TABLE_LIST *tables, TABLE_LIST *leaves,
......
...@@ -372,7 +372,7 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds, ...@@ -372,7 +372,7 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds,
if (conds) if (conds)
{ {
Item::cond_result result; Item::cond_result result;
conds= remove_eq_conds(thd, conds, &result); conds= conds->remove_eq_conds(thd, &result, true);
if (result == Item::COND_FALSE) // Impossible where if (result == Item::COND_FALSE) // Impossible where
{ {
limit= 0; limit= 0;
......
This diff is collapsed.
...@@ -1803,7 +1803,6 @@ bool cp_buffer_from_ref(THD *thd, TABLE *table, TABLE_REF *ref); ...@@ -1803,7 +1803,6 @@ bool cp_buffer_from_ref(THD *thd, TABLE *table, TABLE_REF *ref);
bool error_if_full_join(JOIN *join); bool error_if_full_join(JOIN *join);
int report_error(TABLE *table, int error); int report_error(TABLE *table, int error);
int safe_index_read(JOIN_TAB *tab); int safe_index_read(JOIN_TAB *tab);
COND *remove_eq_conds(THD *thd, COND *cond, Item::cond_result *cond_value);
int get_quick_record(SQL_SELECT *select); int get_quick_record(SQL_SELECT *select);
SORT_FIELD * make_unireg_sortorder(THD *thd, ORDER *order, uint *length, SORT_FIELD * make_unireg_sortorder(THD *thd, ORDER *order, uint *length,
SORT_FIELD *sortorder); SORT_FIELD *sortorder);
......
...@@ -377,7 +377,7 @@ int mysql_update(THD *thd, ...@@ -377,7 +377,7 @@ int mysql_update(THD *thd,
if (conds) if (conds)
{ {
Item::cond_result cond_value; Item::cond_result cond_value;
conds= remove_eq_conds(thd, conds, &cond_value); conds= conds->remove_eq_conds(thd, &cond_value, true);
if (cond_value == Item::COND_FALSE) if (cond_value == Item::COND_FALSE)
{ {
limit= 0; // Impossible WHERE limit= 0; // Impossible WHERE
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment