Bug #9499 | equal condition could allow substitution of columns for better key utilization | ||
---|---|---|---|
Submitted: | 30 Mar 2005 20:17 | Modified: | 30 Mar 2005 22:19 |
Reporter: | Timothy Smith | Email Updates: | |
Status: | Closed | Impact on me: | |
Category: | MySQL Server: Optimizer | Severity: | S4 (Feature request) |
Version: | 4.1 | OS: | Any (all) |
Assigned to: | CPU Architecture: | Any |
[30 Mar 2005 20:17]
Timothy Smith
[30 Mar 2005 20:50]
Timothy Smith
Just to be clear, the two queries are logically identical, because of the transitive relationship (if a.b = b.b and b.b like '0%' then a.b like '0%'). The two queries could have the same plan. Timothy
[30 Mar 2005 22:19]
Timothy Smith
This has been implemented as a new feature in 5.0. It may be in the 5.0.4 release.
[30 Mar 2005 22:26]
Dale Johnson
According to mysql documentation: http://dev.mysql.com/doc/mysql/en/where-optimizations.html Some of the optimizations performed by MySQL are listed here: * Removal of unnecessary parentheses: ((a AND b) AND c OR (((a AND b) AND (c AND d)))) -> (a AND b AND c) OR (a AND b AND c AND d) * Constant folding: (a<b AND b=c) AND a=5 -> b>5 AND b=c AND a=5 This is done. So this is clearly a bug and NOT an optimization.
[30 Mar 2005 23:45]
Timothy Smith
Hi, Dale! This is actually very different from the constant propogation that is referred to in the manual. This new optimization has not yet been documented, and is new in MySQL 5.0. It took several logged months of work to produce.