A customer issue has drawn my attention to this this pecularity: if partitioning is done by the value of some function, then partition pruning module will make use of comparisons of the partitioning column(s), but not of comparisons of the value of the partitioning function. Here is an example:
CREATE TABLE t1 ( recdate DATETIME NOT NULL, ... )
PARTITION BY RANGE( TO_DAYS(recdate) ) (
PARTITION p0 VALUES LESS THAN ( TO_DAYS('2007-01-01') ),
PARTITION p1 VALUES LESS THAN ( TO_DAYS('2007-02-01') ),
...
);
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE recdate='2007-01-15';
+----+-------------+-------+------------+------+-...
| id | select_type | table | partitions | type |
+----+-------------+-------+------------+------+-...
| 1 | SIMPLE | t1 | p1 | ALL |
+----+-------------+-------+------------+------+-...
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE TO_DAYS(recdate)=TO_DAYS('2007-01-15'); …[Read more]