diff options
author | Alexander Barkov <bar@mariadb.com> | 2019-03-21 13:43:17 +0400 |
---|---|---|
committer | Alexander Barkov <bar@mariadb.com> | 2019-03-22 07:28:59 +0400 |
commit | f4484dfdbf2d78b0f357916ebd8ade024dd73c09 (patch) | |
tree | 680aca6e1cf1290efd65fa5fa53e936169394422 /sql | |
parent | 482710b20c28e2cdc598dc37468cc5dc06c53ac1 (diff) | |
download | mariadb-git-f4484dfdbf2d78b0f357916ebd8ade024dd73c09.tar.gz |
MDEV-19008 Slow EXPLAIN SELECT ... WHERE col IN (const1,const2,(subquery))
Diffstat (limited to 'sql')
-rw-r--r-- | sql/item.h | 10 | ||||
-rw-r--r-- | sql/item_cmpfunc.h | 2 | ||||
-rw-r--r-- | sql/item_subselect.cc | 6 |
3 files changed, 17 insertions, 1 deletions
diff --git a/sql/item.h b/sql/item.h index 4eab7090276..883cc791f38 100644 --- a/sql/item.h +++ b/sql/item.h @@ -1409,6 +1409,16 @@ public: LOWEST_PRECEDENCE); } virtual void print(String *str, enum_query_type query_type); + + class Print: public String + { + public: + Print(Item *item, enum_query_type type) + { + item->print(this, type); + } + }; + void print_item_w_name(String *str, enum_query_type query_type); void print_value(String *str); diff --git a/sql/item_cmpfunc.h b/sql/item_cmpfunc.h index 4a1202837f4..06f15503258 100644 --- a/sql/item_cmpfunc.h +++ b/sql/item_cmpfunc.h @@ -2281,7 +2281,7 @@ class Item_func_in :public Item_func_opt_neg, { for (uint i= 0; i < nitems; i++) { - if (!items[i]->const_item()) + if (!items[i]->const_item() || items[i]->is_expensive()) return false; } return true; diff --git a/sql/item_subselect.cc b/sql/item_subselect.cc index 207aa9a25c9..cd411c5d4c1 100644 --- a/sql/item_subselect.cc +++ b/sql/item_subselect.cc @@ -710,6 +710,12 @@ bool Item_subselect::exec() DBUG_ENTER("Item_subselect::exec"); DBUG_ASSERT(fixed); + DBUG_EXECUTE_IF("Item_subselect", + push_warning_printf(thd, Sql_condition::WARN_LEVEL_NOTE, + ER_UNKNOWN_ERROR, "DBUG: Item_subselect::exec %s", + Item::Print(this, + enum_query_type(QT_TO_SYSTEM_CHARSET | + QT_WITHOUT_INTRODUCERS)).ptr());); /* Do not execute subselect in case of a fatal error or if the query has been killed. |