Bug #27927 | Partition pruning not optimal with TO_DAYS function | ||
---|---|---|---|
Submitted: | 18 Apr 2007 12:53 | Modified: | 24 Sep 2007 12:42 |
Reporter: | David Shrewsbury | Email Updates: | |
Status: | Closed | Impact on me: | |
Category: | MySQL Server: Partitions | Severity: | S3 (Non-critical) |
Version: | 5.1.17 | OS: | Linux |
Assigned to: | Sergey Petrunya | CPU Architecture: | Any |
[18 Apr 2007 12:53]
David Shrewsbury
[19 Apr 2007 7:50]
Sveta Smirnova
Thank you for the report. Verified as described.
[26 May 2007 0:02]
Sergey Petrunya
Analysis: The predicate recdate < '2007-03-08 00:00:00' is processed as follows: TO_DAYS(datetime) is known as MONOTONIC_INCREASING, i.e. the optimizer knows about TO_DAYS that it satisfies F() is unary and (x < y) ==> (F(x) <= F(y)) so, recdate < '2007-03-08 00:00:00' gets converted to TO_DAYS(recdate) <= TO_DAYS('2007-03-08 00:00:00') The "or-equal" is why partition p1 is used.
[26 May 2007 0:29]
Sergey Petrunya
...So the observed effect is kind of expected. A possible solution ------------------- At the moment the only functions that are known to be MONOTONIC_INCREASING are: TO_DAYS(datetime_field), YEAR(date_column), YEAR(datetime_column) For those functions, greater-than comparisons can only be converted to greater-or-equal: (field > const) -> (FUNC(field) >= FUNC(const)) But less-than comparisons can be converted to less-than (and not less-or-equal): (field < const) -> (FUNC(val) < FUNC(const)) (*) This makes it possible to make the following fix: * Change the meaning of MONOTONIC_INCREASING so it allows conversions like (*); * Replace declaration/use partition_info::range_analysis_include_bounds so that conversion (*) takes place.
[10 Sep 2007 22:18]
Bugs System
A patch for this bug has been committed. After review, it may be pushed to the relevant source trees for release in the next version. You can access the patch from: http://lists.mysql.com/commits/34021 ChangeSet@1.2603, 2007-09-11 02:17:19+04:00, sergefp@mysql.com +7 -0 BUG#27927 Partition pruning not optimal with TO_DAYS and YEAR functions - Introduced val_int_endpoint() function which converts between func argument intervals and func value intervals for monotonic functions. - Made partition interval analyzer use part_expr->val_int_endpoint() to check if the edge values should be included.
[14 Sep 2007 10:19]
Bugs System
A patch for this bug has been committed. After review, it may be pushed to the relevant source trees for release in the next version. You can access the patch from: http://lists.mysql.com/commits/34257 ChangeSet@1.2603, 2007-09-14 14:18:42+04:00, sergefp@mysql.com +8 -0 BUG#27927:Partition pruning not optimal with TO_DAYS and YEAR functions - Introduced val_int_endpoint() function which converts between func argument intervals and func value intervals for monotonic functions. - Made partition interval analyzer use part_expr->val_int_endpoint() to check if the edge values should be included.
[24 Sep 2007 8:34]
Bugs System
Pushed into 5.1.23-beta
[24 Sep 2007 12:42]
Jon Stephens
Thank you for your bug report. This issue has been committed to our source repository of that product and will be incorporated into the next release. If necessary, you can access the source repository and build the latest available version, including the bug fix. More information about accessing the source trees is available at http://dev.mysql.com/doc/en/installing-source.html Documented as follows in 5.1.23 changelog: Partition pruning was not used for queries having <= or >= conditions in the WHERE clause on a table using TO_DAYS() in the partitioning expression.