CREATE TABLE `tmp` (
`CallID` bigint(8) unsigned NOT NULL,
`InfoID` bigint(8) unsigned NOT NULL,
`CallStartTime` datetime NOT NULL,
`PartitionID` int(4) unsigned NOT NULL,
KEY `CallStartTime`(`CallStartTime`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
PARTITION BY RANGE (`PartitionID`)(
PARTITION p0 VALUES LESS THAN ( 50 ),
PARTITION p1 VALUES LESS THAN ( 100 ),
PARTITION p2 VALUES LESS THAN ( 150 ),
PARTITION p3 VALUES LESS THAN ( 200 ),
PARTITION p4 VALUES LESS THAN ( 250 ),
PARTITION p5 VALUES LESS THAN ( 300 ),
PARTITION p6 VALUES LESS THAN ( 350 ),
PARTITION p7 VALUES LESS THAN MAXVALUE );
我正在执行此查询:
EXPLAIN PARTITIONS
SELECT *
FROM tmp
WHERE (`PartitionID` BETWEEN dayofyear('2013-06-19 01:00:00')
AND dayofyear('2013-08-13 12:10:06') )
AND (CallStartTime BETWEEN '2013-06-19 01:00:00' AND '2013-08-13 12:10:06')
结果:
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE tmp p3,p4 ALL CallStartTime 11 Using where