SELECT * FROM tableNmae PARTITION (partitionName); as taken from http://dev.mysql.com/doc/refman/5.6/en/partitioning-selection.html can be used to restrict SELECT's to only one partition. So because you know the relation between the partition and the date that you are using, this is trivial.
MYSQL Partition avoid full scan table
문제
Back ground: I have 8 million records and i want to speed up the Query time this is my table
CREATE TABLE vehiclelog3 (
ID INT(100) NOT NULL AUTO_INCREMENT,
`PNumber` VARCHAR(30) DEFAULT NULL,
`Date` DATE DEFAULT NULL,
`Time` TIME DEFAULT NULL,
`Offset` VARCHAR(45) DEFAULT NULL,
`Street1` VARCHAR(60) DEFAULT NULL,
`Street2` VARCHAR(60) DEFAULT NULL,
`City` VARCHAR(60) DEFAULT NULL,
`Region` VARCHAR(60) DEFAULT NULL,
ect...
PRIMARY KEY (`ID`,`Date`),
UNIQUE KEY ID (`ID`,`Date`),
KEY date (`Date`),
KEY plate (`PNumber`)
) ENGINE=INNODB
PARTITION BY HASH( MONTH(`Date`) )
PARTITIONS 12;
My problem is i want to avoid full scan to table for example if my query is like
EXPLAIN PARTITIONS Select * from vehiclelog3 where PNumber = "bla" and Date = "2014-01-18"
output:
1 SIMPLE vehiclelog3 p1,p2,p3,p4,p5,p6,p7,p8,p9,p10,p11,p12 index (NULL) PRIMARY 7 (NULL) 3346217 Using where
i just want to scan only the partition that have that data. Is it possible?
해결책
제휴하지 않습니다 StackOverflow