> mysql [localhost] {msandbox} (test) > explain partitions select * FROM t2 WHERE time_segment = '2016-04-29 09:30:00';
|
> +------+-------------+-------+------------+------+---------------+---------+---------+-------+------+-------------+
|
> | id | select_type | table | partitions | type | possible_keys | key | key_len | ref | rows | Extra |
|
> +------+-------------+-------+------------+------+---------------+---------+---------+-------+------+-------------+
|
> | 1 | SIMPLE | t2 | p4 | ref | PRIMARY | PRIMARY | 5 | const | 1 | Using index |
|
> +------+-------------+-------+------------+------+---------------+---------+---------+-------+------+-------------+
|
> 1 row in set (0.00 sec)
|
|
> mysql [localhost] {msandbox} (test) > explain partitions select * FROM t2 WHERE date(time_segment) = '2016-04-29'; <<<< ***************** You see another pruning problem when using a function (date). *******
|
> +------+-------------+-------+----------------+-------+---------------+---------+---------+------+------+--------------------------+
|
> | id | select_type | table | partitions | type | possible_keys | key | key_len | ref | rows | Extra |
|
> +------+-------------+-------+----------------+-------+---------------+---------+---------+------+------+--------------------------+
|
> | 1 | SIMPLE | t2 | p0,p1,p2,p3,p4 | index | NULL | PRIMARY | 9 | NULL | 6 | Using where; Using index |
|
> +------+-------------+-------+----------------+-------+---------------+---------+---------+------+------+--------------------------+
|
> 1 row in set (0.00 sec)
|