mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
MDEV-8553: Impossible where for a!=a, a<a, a>a
For a table column `a`, the above expressions logically equate to false in all cases. With this patch the optimizer knows about this and queries like: SELECT * FROM t1 WHERE a!=a no longer need to evaluate a!=a for every row. The same applies if the expression was `a<a`, or `a>a` An `EXPLAIN SELECT COOUNT(*) FROM t1 WHERE a<a` will show: id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE Similarly `NOT (a!=a)` is always true. EXPLAIN SELECT COUNT(*) FROM t1 WHERE not (a!=a); id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
This commit is contained in:
committed by
Sergey Vojtovich
parent
ad36d38024
commit
d2fa5f8cfc
@ -17109,7 +17109,8 @@ Item_bool_func2::remove_eq_conds(THD *thd, Item::cond_result *cond_value,
|
||||
{
|
||||
if (args[0]->eq(args[1], true))
|
||||
{
|
||||
if (!args[0]->maybe_null || functype() == Item_func::EQUAL_FUNC)
|
||||
if (*cond_value == Item::COND_FALSE ||
|
||||
!args[0]->maybe_null || functype() == Item_func::EQUAL_FUNC)
|
||||
return (COND*) 0; // Compare of identical items
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user