创建分区表(test):
CREATE TABLE test( id INT, time datetime ) PARTITION BY RANGE(TO_DAYS(`time`)) ( PARTITION part1 VALUES less than (TO_DAYS('2012-01-01')), PARTITION part2 VALUES less than (TO_DAYS('2012-04-01')), PARTITION part3 VALUES less than (TO_DAYS('2012-07-01')), PARTITION part4 VALUES less than (TO_DAYS('2012-10-1')), PARTITION part5 VALUES less than MAXVALUE); )
写入数据:
INSERT INTO test VALUES(1,'2012-02-12'),(2,'2012-03-12'),(3,'2012-04-05'),(4,'2012-05-15'),(5,'2012-08-25'),(6,'2012-10-01')
问题:
EXPLAIN PARTITIONS SELECT * FROM test WHERE time>DATE('2012-7-1') AND time<DATE('2012-10-1')
会检索分区1和分区4:part1,part4
照创建分区的过程,应该只检索:part4
-------------------------------------------
试了几个例子,都会检索分区1,问题是分区1存放的应该是:2012-01-01之前的数据