为提高效率,请提供以下信息,问题描述清晰能够更快得到解决:
【 TiDB 使用环境】v5.1.1
【概述】 场景 + 问题概述:对一个有tiflash副本的表执行sql,查看计划,底层的执行引擎居然不一样
表结构:
CREATE TABLE `dwd_resource` (
`event_id` varchar(255) DEFAULT NULL,
`event_time` date DEFAULT NULL,
`user_id` varchar(255) DEFAULT NULL,
`user_type` varchar(255) DEFAULT NULL,
`institution` varchar(255) DEFAULT NULL,
`pid` varchar(255) DEFAULT NULL,
`ip` varchar(255) DEFAULT NULL,
`operate_type` int(11) DEFAULT NULL,
`authtoken` text DEFAULT NULL,
`channelId` varchar(255) DEFAULT NULL,
`deduction` varchar(255) DEFAULT NULL,
`exportSize` int(11) DEFAULT NULL,
`module` varchar(255) DEFAULT NULL,
`perio_id` varchar(255) DEFAULT NULL,
`perio_name` text DEFAULT NULL,
`publish_year` varchar(255) DEFAULT NULL,
`resource_title` text DEFAULT NULL,
`resource_type` varchar(255) DEFAULT NULL,
`language` varchar(20) DEFAULT NULL,
`producer` varchar(255) DEFAULT NULL,
`source_db` text DEFAULT NULL,
`source_id` varchar(255) DEFAULT NULL,
KEY `idx_module` (`module`),
KEY `idx_operate_type` (`operate_type`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin
PARTITION BY RANGE COLUMNS(event_time) (
PARTITION `p202001` VALUES LESS THAN ("2020-02-01"),
PARTITION `p202002` VALUES LESS THAN ("2020-03-01"),
PARTITION `p202003` VALUES LESS THAN ("2020-04-01"),
PARTITION `p202004` VALUES LESS THAN ("2020-05-01"),
PARTITION `p202005` VALUES LESS THAN ("2020-06-01"),
PARTITION `p202006` VALUES LESS THAN ("2020-07-01"),
PARTITION `p202007` VALUES LESS THAN ("2020-08-01"),
PARTITION `p202008` VALUES LESS THAN ("2020-09-01"),
PARTITION `p202009` VALUES LESS THAN ("2020-10-01"),
PARTITION `p202010` VALUES LESS THAN ("2020-11-01"),
PARTITION `p202011` VALUES LESS THAN ("2020-12-01"),
PARTITION `p202012` VALUES LESS THAN ("2021-01-01"),
PARTITION `p202101` VALUES LESS THAN ("2021-02-01"),
PARTITION `p202102` VALUES LESS THAN ("2021-03-01"),
PARTITION `p202103` VALUES LESS THAN ("2021-04-01"),
PARTITION `p202104` VALUES LESS THAN ("2021-05-01"),
PARTITION `p202105` VALUES LESS THAN ("2021-06-01"),
PARTITION `p202107` VALUES LESS THAN ("2021-08-01"),
PARTITION `p202108` VALUES LESS THAN ("2021-09-01"),
PARTITION `p202109` VALUES LESS THAN ("2021-10-01"),
PARTITION `p202110` VALUES LESS THAN ("2021-11-01"),
PARTITION `p202111` VALUES LESS THAN ("2021-12-01"),
PARTITION `p202112` VALUES LESS THAN ("2022-01-01")
);
查询语句:
desc SELECT
str_to_date(
concat(
date_format(`dwd_resource`.`event_time`, '%Y-%m'),
'-01'
),
'%Y-%m-%d'
) AS `event_time`,
count(*) AS `count`
FROM
`dwd_resource`
WHERE
(
(
`dwd_resource`.`operate_type` = 2
OR `dwd_resource`.`operate_type` = 17
)
AND `dwd_resource`.`event_time` >= '2021-01-01 00:00:00'
AND `dwd_resource`.`event_time` < '2021-07-01 00:00:00'
)
GROUP BY
str_to_date(
concat(
date_format(`dwd_resource`.`event_time`, '%Y-%m'),
'-01'
),
'%Y-%m-%d'
)
ORDER BY
str_to_date(
concat(
date_format(`dwd_resource`.`event_time`, '%Y-%m'),
'-01'
),
'%Y-%m-%d'
) ASC
执行计划: