只是将普通表转为分区表,查询报错。
普通表结构:
CREATE TABLE `middle_data_spider_task_log_new` (
`id` bigint(11) NOT NULL AUTO_INCREMENT COMMENT '主键id',
`promote_platform_type` int(5) NOT NULL COMMENT '第三方推广平台类型 1抖音,2有赞,3快手 6视频号',
`relate_institution_id` varchar(100) NOT NULL COMMENT '第三方机构ID。',
`relate_institution_name` varchar(100) DEFAULT NULL COMMENT '第三方机构名称。',
`role_type` varchar(50) DEFAULT NULL COMMENT '第三方角色,leader团长后台,mcn是MCN后台,dk是抖客后台,shop是商家后台,salesman是达人后台。',
`task_fast_flag` int(5) NOT NULL COMMENT '任务模式,1普通,2重点,3实时',
`task_param` text NOT NULL COMMENT '任务参数,达人公海是抖音号id,通用任务时是url+header+post的参数',
`task_location_href` varchar(600) DEFAULT NULL COMMENT '任务请求的落地页,部分请求接口,必须在某个页面调用。',
`task_status` int(5) NOT NULL DEFAULT '0' COMMENT '任务状态:0 未执行 , 1 执行中 , 2 执行完成,3放弃执行(已等待超时)',
`get_task_time` datetime DEFAULT NULL COMMENT '任务领取时间',
`finish_task_time` datetime DEFAULT NULL COMMENT '任务完成时间',
`task_context_data` varchar(300) DEFAULT NULL COMMENT '任务上下文数据。例如达人数据的平台,抖音号。',
`subscribe_config_sync_type` int(5) DEFAULT NULL COMMENT '订阅通知类型,1达人,2达人+商品,3达人联系方式。',
`create_time` datetime NOT NULL COMMENT '创建时间',
PRIMARY KEY (`id`) /*T![clustered_index] NONCLUSTERED */,
KEY `idx_task_order` (`promote_platform_type`,`relate_institution_id`,`role_type`,`task_fast_flag`,`task_status`,`create_time`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin AUTO_INCREMENT=90001 /*T! SHARD_ROW_ID_BITS=4 PRE_SPLIT_REGIONS=2 */ COMMENT='数据模块_爬虫任务表
分区表结构:
CREATE TABLE `middle_data_spider_task_log_new_20240911_15` (
`id` bigint(11) NOT NULL AUTO_INCREMENT COMMENT '主键id',
`promote_platform_type` int(5) NOT NULL COMMENT '第三方推广平台类型 1抖音,2有赞,3快手 6视频号',
`relate_institution_id` varchar(100) NOT NULL COMMENT '第三方机构ID。',
`relate_institution_name` varchar(100) DEFAULT NULL COMMENT '第三方机构名称。',
`role_type` varchar(50) DEFAULT NULL COMMENT '第三方角色,leader团长后台,mcn是MCN后台,dk是抖客后台,shop是商家后台,salesman是达人后台。',
`task_fast_flag` int(5) NOT NULL COMMENT '任务模式,1普通,2重点,3实时',
`task_param` text NOT NULL COMMENT '任务参数,达人公海是抖音号id,通用任务时是url+header+post的参数',
`task_location_href` varchar(600) DEFAULT NULL COMMENT '任务请求的落地页,部分请求接口,必须在某个页面调用。',
`task_status` int(5) NOT NULL DEFAULT '0' COMMENT '任务状态:0 未执行 , 1 执行中 , 2 执行完成,3放弃执行(已等待超时)',
`get_task_time` datetime DEFAULT NULL COMMENT '任务领取时间',
`finish_task_time` datetime DEFAULT NULL COMMENT '任务完成时间',
`task_context_data` varchar(300) DEFAULT NULL COMMENT '任务上下文数据。例如达人数据的平台,抖音号。',
`subscribe_config_sync_type` int(5) DEFAULT NULL COMMENT '订阅通知类型,1达人,2达人+商品,3达人联系方式。',
`create_time` datetime NOT NULL COMMENT '创建时间',
PRIMARY KEY (`id`,`create_time`) /*T![clustered_index] NONCLUSTERED */,
KEY `idx_task_order` (`promote_platform_type`,`relate_institution_id`,`role_type`,`task_fast_flag`,`task_status`,`create_time`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin AUTO_INCREMENT=180001 /*T! SHARD_ROW_ID_BITS=4 PRE_SPLIT_REGIONS=2 */ COMMENT='数据模块_爬虫任务表'
PARTITION BY RANGE COLUMNS(`create_time`)
(PARTITION `p20240908` VALUES LESS THAN ('2024-09-09'),
PARTITION `p20240909` VALUES LESS THAN ('2024-09-10'),
PARTITION `p20240910` VALUES LESS THAN ('2024-09-11'),
PARTITION `p20240911` VALUES LESS THAN ('2024-09-12'),
PARTITION `p20240912` VALUES LESS THAN ('2024-09-13'),
PARTITION `p20240913` VALUES LESS THAN ('2024-09-14'),
PARTITION `p20240914` VALUES LESS THAN ('2024-09-15'),
PARTITION `p20240915` VALUES LESS THAN ('2024-09-16'))
查询SQL:
SELECT
a.id,
a.promote_platform_type,
a.relate_institution_id,
a.relate_institution_name,
a.role_type,
a.task_fast_flag,
a.task_param,
a.task_location_href,
a.task_status,
a.get_task_time,
a.finish_task_time,
a.task_context_data,
a.subscribe_config_sync_type,
a.create_time
FROM
middle_data_spider_task_log_new AS a
WHERE a.promote_platform_type = 1
AND a.relate_institution_id = "3485472482293633334"
AND a.role_type = "leader"
AND a.task_fast_flag = 100
AND a.task_status = 0
ORDER BY
create_time ASC
LIMIT 1
执行计划:
| id | estRows | estCost | actRows | task | access object | execution info | operator info | memory | disk |
| TopN_27 | 0.00 | 247.00 | 0 | root | | time:426.9µs, loops:1 | middleground.middle_data_spider_task_log_new.create_time, offset:0, count:1 | 0 Bytes | N/A |
| └─PartitionUnion_32 | 0.00 | 0.00 | 0 | root | | time:403.3µs, loops:1 | | N/A | N/A |
| ├─Projection_50 | 0.00 | 0.00 | 0 | root | | time:34.2µs, loops:1, Concurrency:OFF | middleground.middle_data_spider_task_log_new.id, middleground.middle_data_spider_task_log_new.promote_platform_type, middleground.middle_data_spider_task_log_new.relate_institution_id, middleground.middle_data_spider_task_log_new.relate_institution_name, middleground.middle_data_spider_task_log_new.role_type, middleground.middle_data_spider_task_log_new.task_fast_flag, middleground.middle_data_spider_task_log_new.task_param, middleground.middle_data_spider_task_log_new.task_location_href, middleground.middle_data_spider_task_log_new.task_status, middleground.middle_data_spider_task_log_new.get_task_time, middleground.middle_data_spider_task_log_new.finish_task_time, middleground.middle_data_spider_task_log_new.task_context_data, middleground.middle_data_spider_task_log_new.subscribe_config_sync_type, middleground.middle_data_spider_task_log_new.create_time | 7.07 KB | N/A |
| │ └─IndexLookUp_49 | 0.00 | 0.00 | 0 | root | partition:all | time:27.1µs, loops:1 | limit embedded(offset:0, count:1) | 0 Bytes | N/A |
| │ ├─Limit_48(Build) | 0.00 | 0.00 | 0 | cop[tikv] | | | offset:0, count:1 | N/A | N/A |
| │ │ └─IndexRangeScan_46 | 0.00 | 0.00 | 0 | cop[tikv] | table:a, partition:p20240908, index:idx_task_order(promote_platform_type, relate_institution_id, role_type, task_fast_flag, task_status, create_time) | | range:[1 "3485472482293633334" "leader" 100 0,1 "3485472482293633334" "leader" 100 0], keep order:true, stats:pseudo | N/A | N/A |
| │ └─TableRowIDScan_47(Probe) | 0.00 | 0.00 | 0 | cop[tikv] | table:a, partition:p20240908 | | keep order:false, stats:pseudo | N/A | N/A |
| ├─Projection_69 | 0.00 | 0.00 | 0 | root | | time:29.4µs, loops:1, Concurrency:OFF | middleground.middle_data_spider_task_log_new.id, middleground.middle_data_spider_task_log_new.promote_platform_type, middleground.middle_data_spider_task_log_new.relate_institution_id, middleground.middle_data_spider_task_log_new.relate_institution_name, middleground.middle_data_spider_task_log_new.role_type, middleground.middle_data_spider_task_log_new.task_fast_flag, middleground.middle_data_spider_task_log_new.task_param, middleground.middle_data_spider_task_log_new.task_location_href, middleground.middle_data_spider_task_log_new.task_status, middleground.middle_data_spider_task_log_new.get_task_time, middleground.middle_data_spider_task_log_new.finish_task_time, middleground.middle_data_spider_task_log_new.task_context_data, middleground.middle_data_spider_task_log_new.subscribe_config_sync_type, middleground.middle_data_spider_task_log_new.create_time | 7.07 KB | N/A |
| │ └─IndexLookUp_68 | 0.00 | 0.00 | 0 | root | partition:all | time:20.8µs, loops:1 | limit embedded(offset:0, count:1) | 0 Bytes | N/A |
| │ ├─Limit_67(Build) | 0.00 | 0.00 | 0 | cop[tikv] | | | offset:0, count:1 | N/A | N/A |
| │ │ └─IndexRangeScan_65 | 0.00 | 0.00 | 0 | cop[tikv] | table:a, partition:p20240909, index:idx_task_order(promote_platform_type, relate_institution_id, role_type, task_fast_flag, task_status, create_time) | | range:[1 "3485472482293633334" "leader" 100 0,1 "3485472482293633334" "leader" 100 0], keep order:true, stats:pseudo | N/A | N/A |
| │ └─TableRowIDScan_66(Probe) | 0.00 | 0.00 | 0 | cop[tikv] | table:a, partition:p20240909 | | keep order:false, stats:pseudo | N/A | N/A |
| ├─Projection_88 | 0.00 | 0.00 | 0 | root | | time:25.4µs, loops:1, Concurrency:OFF | middleground.middle_data_spider_task_log_new.id, middleground.middle_data_spider_task_log_new.promote_platform_type, middleground.middle_data_spider_task_log_new.relate_institution_id, middleground.middle_data_spider_task_log_new.relate_institution_name, middleground.middle_data_spider_task_log_new.role_type, middleground.middle_data_spider_task_log_new.task_fast_flag, middleground.middle_data_spider_task_log_new.task_param, middleground.middle_data_spider_task_log_new.task_location_href, middleground.middle_data_spider_task_log_new.task_status, middleground.middle_data_spider_task_log_new.get_task_time, middleground.middle_data_spider_task_log_new.finish_task_time, middleground.middle_data_spider_task_log_new.task_context_data, middleground.middle_data_spider_task_log_new.subscribe_config_sync_type, middleground.middle_data_spider_task_log_new.create_time | 7.07 KB | N/A |
| │ └─IndexLookUp_87 | 0.00 | 0.00 | 0 | root | partition:all | time:17µs, loops:1 | limit embedded(offset:0, count:1) | 0 Bytes | N/A |
| │ ├─Limit_86(Build) | 0.00 | 0.00 | 0 | cop[tikv] | | | offset:0, count:1 | N/A | N/A |
| │ │ └─IndexRangeScan_84 | 0.00 | 0.00 | 0 | cop[tikv] | table:a, partition:p20240910, index:idx_task_order(promote_platform_type, relate_institution_id, role_type, task_fast_flag, task_status, create_time) | | range:[1 "3485472482293633334" "leader" 100 0,1 "3485472482293633334" "leader" 100 0], keep order:true, stats:pseudo | N/A | N/A |
| │ └─TableRowIDScan_85(Probe) | 0.00 | 0.00 | 0 | cop[tikv] | table:a, partition:p20240910 | | keep order:false, stats:pseudo | N/A | N/A |
| ├─Projection_107 | 0.00 | 0.00 | 0 | root | | time:0s, loops:0, Concurrency:OFF | middleground.middle_data_spider_task_log_new.id, middleground.middle_data_spider_task_log_new.promote_platform_type, middleground.middle_data_spider_task_log_new.relate_institution_id, middleground.middle_data_spider_task_log_new.relate_institution_name, middleground.middle_data_spider_task_log_new.role_type, middleground.middle_data_spider_task_log_new.task_fast_flag, middleground.middle_data_spider_task_log_new.task_param, middleground.middle_data_spider_task_log_new.task_location_href, middleground.middle_data_spider_task_log_new.task_status, middleground.middle_data_spider_task_log_new.get_task_time, middleground.middle_data_spider_task_log_new.finish_task_time, middleground.middle_data_spider_task_log_new.task_context_data, middleground.middle_data_spider_task_log_new.subscribe_config_sync_type, middleground.middle_data_spider_task_log_new.create_time | 7.07 KB | N/A |
| │ └─IndexLookUp_106 | 0.00 | 0.00 | 0 | root | partition:all | time:0s, loops:0 | limit embedded(offset:0, count:1) | 0 Bytes | N/A |
| │ ├─Limit_105(Build) | 0.00 | 0.00 | 0 | cop[tikv] | | | offset:0, count:1 | N/A | N/A |
| │ │ └─IndexRangeScan_103 | 0.00 | 0.00 | 0 | cop[tikv] | table:a, partition:p20240911, index:idx_task_order(promote_platform_type, relate_institution_id, role_type, task_fast_flag, task_status, create_time) | | range:[1 "3485472482293633334" "leader" 100 0,1 "3485472482293633334" "leader" 100 0], keep order:true, stats:pseudo | N/A | N/A |
| │ └─TableRowIDScan_104(Probe) | 0.00 | 0.00 | 0 | cop[tikv] | table:a, partition:p20240911 | | keep order:false, stats:pseudo | N/A | N/A |
| ├─Projection_126 | 0.00 | 0.00 | 0 | root | | time:0s, loops:0, Concurrency:OFF | middleground.middle_data_spider_task_log_new.id, middleground.middle_data_spider_task_log_new.promote_platform_type, middleground.middle_data_spider_task_log_new.relate_institution_id, middleground.middle_data_spider_task_log_new.relate_institution_name, middleground.middle_data_spider_task_log_new.role_type, middleground.middle_data_spider_task_log_new.task_fast_flag, middleground.middle_data_spider_task_log_new.task_param, middleground.middle_data_spider_task_log_new.task_location_href, middleground.middle_data_spider_task_log_new.task_status, middleground.middle_data_spider_task_log_new.get_task_time, middleground.middle_data_spider_task_log_new.finish_task_time, middleground.middle_data_spider_task_log_new.task_context_data, middleground.middle_data_spider_task_log_new.subscribe_config_sync_type, middleground.middle_data_spider_task_log_new.create_time | 7.07 KB | N/A |
| │ └─IndexLookUp_125 | 0.00 | 0.00 | 0 | root | partition:all | time:0s, loops:0 | limit embedded(offset:0, count:1) | 0 Bytes | N/A |
| │ ├─Limit_124(Build) | 0.00 | 0.00 | 0 | cop[tikv] | | | offset:0, count:1 | N/A | N/A |
| │ │ └─IndexRangeScan_122 | 0.00 | 0.00 | 0 | cop[tikv] | table:a, partition:p20240912, index:idx_task_order(promote_platform_type, relate_institution_id, role_type, task_fast_flag, task_status, create_time) | | range:[1 "3485472482293633334" "leader" 100 0,1 "3485472482293633334" "leader" 100 0], keep order:true, stats:pseudo | N/A | N/A |
| │ └─TableRowIDScan_123(Probe) | 0.00 | 0.00 | 0 | cop[tikv] | table:a, partition:p20240912 | | keep order:false, stats:pseudo | N/A | N/A |
| ├─Projection_145 | 0.00 | 0.00 | 0 | root | | time:0s, loops:0 | middleground.middle_data_spider_task_log_new.id, middleground.middle_data_spider_task_log_new.promote_platform_type, middleground.middle_data_spider_task_log_new.relate_institution_id, middleground.middle_data_spider_task_log_new.relate_institution_name, middleground.middle_data_spider_task_log_new.role_type, middleground.middle_data_spider_task_log_new.task_fast_flag, middleground.middle_data_spider_task_log_new.task_param, middleground.middle_data_spider_task_log_new.task_location_href, middleground.middle_data_spider_task_log_new.task_status, middleground.middle_data_spider_task_log_new.get_task_time, middleground.middle_data_spider_task_log_new.finish_task_time, middleground.middle_data_spider_task_log_new.task_context_data, middleground.middle_data_spider_task_log_new.subscribe_config_sync_type, middleground.middle_data_spider_task_log_new.create_time | N/A | N/A |
| │ └─IndexLookUp_144 | 0.00 | 0.00 | 0 | root | partition:all | time:0s, loops:0 | limit embedded(offset:0, count:1) | N/A | N/A |
| │ ├─Limit_143(Build) | 0.00 | 0.00 | 0 | cop[tikv] | | | offset:0, count:1 | N/A | N/A |
| │ │ └─IndexRangeScan_141 | 0.00 | 0.00 | 0 | cop[tikv] | table:a, partition:p20240913, index:idx_task_order(promote_platform_type, relate_institution_id, role_type, task_fast_flag, task_status, create_time) | | range:[1 "3485472482293633334" "leader" 100 0,1 "3485472482293633334" "leader" 100 0], keep order:true, stats:pseudo | N/A | N/A |
| │ └─TableRowIDScan_142(Probe) | 0.00 | 0.00 | 0 | cop[tikv] | table:a, partition:p20240913 | | keep order:false, stats:pseudo | N/A | N/A |
| ├─Projection_164 | 0.00 | 0.00 | 0 | root | | time:0s, loops:0 | middleground.middle_data_spider_task_log_new.id, middleground.middle_data_spider_task_log_new.promote_platform_type, middleground.middle_data_spider_task_log_new.relate_institution_id, middleground.middle_data_spider_task_log_new.relate_institution_name, middleground.middle_data_spider_task_log_new.role_type, middleground.middle_data_spider_task_log_new.task_fast_flag, middleground.middle_data_spider_task_log_new.task_param, middleground.middle_data_spider_task_log_new.task_location_href, middleground.middle_data_spider_task_log_new.task_status, middleground.middle_data_spider_task_log_new.get_task_time, middleground.middle_data_spider_task_log_new.finish_task_time, middleground.middle_data_spider_task_log_new.task_context_data, middleground.middle_data_spider_task_log_new.subscribe_config_sync_type, middleground.middle_data_spider_task_log_new.create_time | N/A | N/A |
| │ └─IndexLookUp_163 | 0.00 | 0.00 | 0 | root | partition:all | time:0s, loops:0 | limit embedded(offset:0, count:1) | N/A | N/A |
| │ ├─Limit_162(Build) | 0.00 | 0.00 | 0 | cop[tikv] | | | offset:0, count:1 | N/A | N/A |
| │ │ └─IndexRangeScan_160 | 0.00 | 0.00 | 0 | cop[tikv] | table:a, partition:p20240914, index:idx_task_order(promote_platform_type, relate_institution_id, role_type, task_fast_flag, task_status, create_time) | | range:[1 "3485472482293633334" "leader" 100 0,1 "3485472482293633334" "leader" 100 0], keep order:true, stats:pseudo | N/A | N/A |
| │ └─TableRowIDScan_161(Probe) | 0.00 | 0.00 | 0 | cop[tikv] | table:a, partition:p20240914 | | keep order:false, stats:pseudo | N/A | N/A |
| └─Projection_183 | 0.00 | 0.00 | 0 | root | | time:0s, loops:0 | middleground.middle_data_spider_task_log_new.id, middleground.middle_data_spider_task_log_new.promote_platform_type, middleground.middle_data_spider_task_log_new.relate_institution_id, middleground.middle_data_spider_task_log_new.relate_institution_name, middleground.middle_data_spider_task_log_new.role_type, middleground.middle_data_spider_task_log_new.task_fast_flag, middleground.middle_data_spider_task_log_new.task_param, middleground.middle_data_spider_task_log_new.task_location_href, middleground.middle_data_spider_task_log_new.task_status, middleground.middle_data_spider_task_log_new.get_task_time, middleground.middle_data_spider_task_log_new.finish_task_time, middleground.middle_data_spider_task_log_new.task_context_data, middleground.middle_data_spider_task_log_new.subscribe_config_sync_type, middleground.middle_data_spider_task_log_new.create_time | N/A | N/A |
| └─IndexLookUp_182 | 0.00 | 0.00 | 0 | root | partition:all | time:0s, loops:0 | limit embedded(offset:0, count:1) | N/A | N/A |
| ├─Limit_181(Build) | 0.00 | 0.00 | 0 | cop[tikv] | | | offset:0, count:1 | N/A | N/A |
| │ └─IndexRangeScan_179 | 0.00 | 0.00 | 0 | cop[tikv] | table:a, partition:p20240915, index:idx_task_order(promote_platform_type, relate_institution_id, role_type, task_fast_flag, task_status, create_time) | | range:[1 "3485472482293633334" "leader" 100 0,1 "3485472482293633334" "leader" 100 0], keep order:true, stats:pseudo | N/A | N/A |
| └─TableRowIDScan_180(Probe) | 0.00 | 0.00 | 0 | cop[tikv] | table:a, partition:p20240915 | | keep order:false, stats:pseudo | N/A | N/A |
报错信息: