DROP TABLE IF EXISTS temp;
CREATE TABLE `temp` (
`CallID` bigint(8) unsigned NOT NULL,
`InfoID` bigint(8) unsigned NOT NULL,
`CallStartTime` datetime NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1
PARTITION BY RANGE (TO_DAYS(CallStartTime))
(
PARTITION p0 VALUES LESS THAN (TO_DAYS('2013-06-01 00:00:00' )),
PARTITION p1 VALUES LESS THAN (TO_DAYS('2013-07-01 00:00:00')),
PARTITION p2 VALUES LESS THAN (TO_DAYS('2013-08-01 00:00:00')),
PARTITION p3 VALUES LESS THAN (TO_DAYS('2013-09-02 00:00:00'))) ;
我在示例查询中使用 EXPLAIN 得到下一个结果:
EXPLAIN PARTITIONS SELECT * FROM temp where CallStartTime >= '2013-07-13 00:10:06' AND CallStartTime <= '2013-07-22 10:24:00'
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE temp p0,p2 ALL 3 使用 where
我不知道为什么它使用不在 BETWEEN 语句中指定的日期之间的 p0 分区。