summaryrefslogtreecommitdiff
path: root/sql/sql_select.h
diff options
context:
space:
mode:
authorEvgeny Potemkin <epotemkin@mysql.com>2009-12-02 00:25:51 +0300
committerEvgeny Potemkin <epotemkin@mysql.com>2009-12-02 00:25:51 +0300
commit9f7d24586b641fde19848dd77776d0fc7b0001f2 (patch)
treef6897e6f5c940d328bb17f29511b4e7dc729185b /sql/sql_select.h
parent17a4c595bcc75b6de82129fe96b7b6245215ea78 (diff)
downloadmariadb-git-9f7d24586b641fde19848dd77776d0fc7b0001f2.tar.gz
Bug#33546: Slowdown on re-evaluation of constant expressions.
Constant expressions in WHERE/HAVING/ON clauses aren't cached and evaluated for each row. This causes slowdown of query execution especially if constant UDF/SP function are used. Now WHERE/HAVING/ON expressions are analyzed in the top-bottom direction with help of the compile function. When analyzer meets a constant item it sets a flag for the tree transformer to cache the item and doesn't allow tree walker to go deeper. Thus, the topmost item of a constant expression if cached. This is done after all other optimizations were applied to WHERE/HAVING/ON expressions A helper function called cache_const_exprs is added to the JOIN class. It calls compile method with caching analyzer and transformer on WHERE, HAVING, ON expressions if they're present. The cache_const_expr_analyzer and cache_const_expr_transformer functions are added to the Item class. The first one check if the item can be cached and the second caches it if so. A new Item_cache_datetime class is derived from the Item_cache class. It caches both int and string values of the underlying item independently to avoid DATETIME aware int-to-string conversion. Thus it completely relies on the ability of the underlying item to correctly convert DATETIME value from int to string and vice versa.
Diffstat (limited to 'sql/sql_select.h')
-rw-r--r--sql/sql_select.h1
1 files changed, 1 insertions, 0 deletions
diff --git a/sql/sql_select.h b/sql/sql_select.h
index e049e4ed765..bdca4b196bc 100644
--- a/sql/sql_select.h
+++ b/sql/sql_select.h
@@ -555,6 +555,7 @@ public:
return (unit == &thd->lex->unit && (unit->fake_select_lex == 0 ||
select_lex == unit->fake_select_lex));
}
+ void cache_const_exprs();
private:
/**
TRUE if the query contains an aggregate function but has no GROUP