【发布时间】:2012-08-16 09:08:07
【问题描述】:
我通过hash(to_days(...))创建了一个带有 MySQL 分区的表。
CREATE TABLE `requestlog` (
`remotehost` varchar(40) DEFAULT NULL,
`user` varchar(255) DEFAULT NULL,
`request_time_str` varchar(40) DEFAULT NULL,
`request_time` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`request_line` varchar(255) DEFAULT NULL,
`status` int(11) DEFAULT NULL,
`bytes` int(11) DEFAULT NULL,
`referer` text,
`useragent` text,
`host` text,
`instance` text,
`ms` int(11) DEFAULT NULL,
`cpu_ms` int(11) DEFAULT NULL,
`api_cpu_ms` int(11) DEFAULT NULL,
`cpm_usd` float DEFAULT NULL,
`queue_name` varchar(40) DEFAULT NULL,
`task_name` varchar(40) DEFAULT NULL,
`loading_request` tinyint(1) DEFAULT NULL,
`pending_ms` int(11) DEFAULT NULL,
`exit_code` int(11) DEFAULT NULL,
`throttle_code` int(11) DEFAULT NULL,
`method` varchar(40) DEFAULT NULL,
`path` varchar(255) DEFAULT NULL,
`querystring` text,
`protocol` varchar(40) DEFAULT NULL,
`applog` text,
`applog0` text,
`applog1` text,
`applog2` text,
`applog3` text,
`applog4` text,
`id` int(11) NOT NULL AUTO_INCREMENT,
`updated` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMES
TAMP,
PRIMARY KEY (`request_time`,`id`),
UNIQUE KEY `path` (`path`,`request_time`,`remotehost`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8
/*!50100 PARTITION BY HASH (to_days(request_time))
PARTITIONS 1000 */
但是,当我执行以下查询时。 explain partitions 结果显示分区修剪不起作用,因为它扫描了属于该表的所有分区...
explain partitions select count(*) from requestlog where to_days(request_time) = '2012-08-01';
我尝试了本文中的示例。解释分区仍然显示它扫描所有分区。 how to partition a table by datetime column?
如何让分区修剪起作用?有什么提示吗?
【问题讨论】:
标签: mysql database-partitioning pruning