【 TiDB 使用环境】生产环境
【 TiDB 版本】v6.1.5
【复现路径】突然这样
【遇到的问题:问题现象及影响】
分区裁剪不生效,导致查询效率低
表结构
CREATE TABLE `firpt_customer_revenue_month` (
`Report_Date` varchar(25) NOT NULL COMMENT '格式:yyyy-mm-dd',
`Customer_Id` varchar(100) NOT NULL COMMENT '客户在易信推财务系统ID',
`Media_Type` int(11) NOT NULL COMMENT 'yxt_finance_platform_media.id 如:1:亿信推,2:广点通,3:微信,4:头条,5:快手,6:千川',
`Confirm_Type` int(11) DEFAULT '2' COMMENT '1:已确认;2:未确认',
`Consume_Cash` bigint(20) DEFAULT NULL COMMENT '消耗金额-现金;单位:分',
`Consume_Virtual` bigint(20) DEFAULT NULL COMMENT '消耗金额-虚拟金;单位:分',
`Consume_Credit` bigint(20) DEFAULT NULL COMMENT '消耗金额-信用金;单位:分',
`Consume_Compensate` bigint(20) DEFAULT NULL,
`Charge_Cash` bigint(20) DEFAULT NULL COMMENT '充值金额-现金;单位:分',
`Charge_Virtual` bigint(20) DEFAULT NULL COMMENT '充值金额-虚拟金;单位:分',
`Charge_Credit` bigint(20) DEFAULT NULL COMMENT '充值金额-信用金;单位:分',
`Charge_Compensate` bigint(20) DEFAULT NULL,
`Cost_Rebate` bigint(20) DEFAULT NULL COMMENT '成本-折让(返点);单位:分',
`Cost_Adjust` bigint(20) DEFAULT NULL,
`Income` bigint(20) DEFAULT NULL,
`Cfm_Income` bigint(20) DEFAULT NULL,
`Cfm_Rebate` bigint(20) DEFAULT NULL,
`Cfm_Adjust` bigint(20) DEFAULT NULL,
`Cost_Cancel` bigint(20) DEFAULT NULL COMMENT '成本-核减;单位:分',
`Incomec_Charge` bigint(20) DEFAULT NULL COMMENT '应收(已确认)-按充值;单位:分',
`Uncfm_Income` bigint(20) DEFAULT NULL,
`Uncfm_Rebate` bigint(20) DEFAULT NULL,
`Incomec_Consume` bigint(20) DEFAULT NULL COMMENT '应收(已确认)-按消耗;单位:分',
`Incomeu_Charge` bigint(20) DEFAULT NULL COMMENT '应收(未确认)-按充值;单位:分',
`Incomeu_Consume` bigint(20) DEFAULT NULL COMMENT '应收(未确认)-按消耗;单位:分',
`retuan_all` bigint(20) DEFAULT NULL COMMENT '财务回款:单位:分',
`Retuan_Charge` bigint(20) DEFAULT NULL COMMENT '回款-按充值;单位:分',
`Retuan_Consume` bigint(20) DEFAULT NULL COMMENT '回款-按消耗;单位:分',
`retuan_all_real` bigint(20) DEFAULT NULL COMMENT '回款-财务回款-当月实际回款:单位:分',
`debt_all` bigint(20) DEFAULT NULL COMMENT '欠款;单位:分',
`Debt_Charge` bigint(20) DEFAULT NULL COMMENT '欠款-按充值;单位:分',
`Debt_Consume` bigint(20) DEFAULT NULL COMMENT '欠款-按消耗;单位:分',
`debt_all_begining` bigint(20) DEFAULT NULL COMMENT '未回款-期初财务应收(取:上期末财务应收):单位:分',
`debt_all_ending` bigint(20) DEFAULT NULL COMMENT '未回款-期末财务应收(取:本期初财务应收 + 应收收入 + 调整 - 财务回款):单位:分',
`Overdue_Total` bigint(20) DEFAULT NULL COMMENT '逾期-总金额;单位:分',
`Overdue_D15` bigint(20) DEFAULT NULL COMMENT '逾期-15天内;单位:分',
`Overdue_D30` bigint(20) DEFAULT NULL COMMENT '逾期-30天内;单位:分',
`Overdue_D60` bigint(20) DEFAULT NULL COMMENT '逾期-60天内;单位:分',
`Last_Modify_Time` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
`Used_Contract_Rebate` int(11) DEFAULT NULL COMMENT 'yxt_finance_contract表中的contract_rebate 合同返点比例(值*10000,按精度0.01保存,比如1%,系统保存为100)',
`Overdue_G60` bigint(20) DEFAULT NULL COMMENT '预期超过60天 单位:分',
`cost_billed_reality_amount` bigint(20) DEFAULT NULL COMMENT '按消耗应结算金额',
`recharge_billed_reality_amount` bigint(20) DEFAULT NULL COMMENT '按充值应结算金额',
`last_modify_user` varchar(200) DEFAULT NULL COMMENT '最后修改人',
`unused_receipt_amount_to_last_month` bigint(20) DEFAULT NULL COMMENT '将已到款未使用的部分累计到最后一个月',
`not_collect_adjust` bigint(20) DEFAULT NULL COMMENT '结算单中 不计入营收报表统计的结算调整金额',
`Overdue_Debt` bigint(20) DEFAULT NULL COMMENT '逾期未回款金额;单位:分',
`Total_Consumed` bigint(20) DEFAULT NULL COMMENT '总消耗-各项消耗总和 单位:分',
`Float_Service_Amount` bigint(20) DEFAULT NULL COMMENT '浮动服务费 单位:分',
`Cfm_Float_Service_Amount` bigint(20) DEFAULT NULL COMMENT '已结算- 浮动服务费 单位:分',
`Uncfm_Float_Service_Amount` bigint(20) DEFAULT NULL COMMENT '未结算- 浮动服务费 单位:分',
`Emar_Contract_Entity` varchar(100) NOT NULL DEFAULT '0' COMMENT '亿玛合同主体',
`Emar_Receipt_Entity` varchar(512) DEFAULT NULL COMMENT '亿玛回款主体',
`Customer_Receipt_Entity` varchar(1512) DEFAULT NULL COMMENT '客户回款主体',
PRIMARY KEY (`Customer_Id`,`Media_Type`,`Emar_Contract_Entity`,`Report_Date`) /*T![clustered_index] NONCLUSTERED */
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='Finance Report for calculating customer''s revenue'
PARTITION BY RANGE COLUMNS(`Report_Date`)
(PARTITION `p0` VALUES LESS THAN ("2019-06-01"),
PARTITION `p1` VALUES LESS THAN ("2019-07-01"),
PARTITION `p2` VALUES LESS THAN ("2019-08-01"),
PARTITION `p3` VALUES LESS THAN ("2019-09-01"),
PARTITION `p4` VALUES LESS THAN ("2019-10-01"),
PARTITION `p5` VALUES LESS THAN ("2019-11-01"),
PARTITION `p6` VALUES LESS THAN ("2019-12-01"),
PARTITION `p7` VALUES LESS THAN ("2020-01-01"),
PARTITION `p8` VALUES LESS THAN ("2020-02-01"),
PARTITION `p9` VALUES LESS THAN ("2020-03-01"),
PARTITION `p10` VALUES LESS THAN ("2020-04-01"),
PARTITION `p11` VALUES LESS THAN ("2020-05-01"),
PARTITION `p12` VALUES LESS THAN ("2020-06-01"),
PARTITION `p13` 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 `p202106` VALUES LESS THAN ("2021-07-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"),
PARTITION `p202201` VALUES LESS THAN ("2022-02-01"),
PARTITION `p202202` VALUES LESS THAN ("2022-03-01"),
PARTITION `p202203` VALUES LESS THAN ("2022-04-01"),
PARTITION `p202204` VALUES LESS THAN ("2022-05-01"),
PARTITION `p202205` VALUES LESS THAN ("2022-06-01"),
PARTITION `p202206` VALUES LESS THAN ("2022-07-01"),
PARTITION `p202207` VALUES LESS THAN ("2022-08-01"),
PARTITION `p202208` VALUES LESS THAN ("2022-09-01"),
PARTITION `p202209` VALUES LESS THAN ("2022-10-01"),
PARTITION `p202210` VALUES LESS THAN ("2022-11-01"),
PARTITION `p202211` VALUES LESS THAN ("2022-12-01"),
PARTITION `p202212` VALUES LESS THAN ("2023-01-01"),
PARTITION `p202301` VALUES LESS THAN ("2023-02-01"),
PARTITION `p202302` VALUES LESS THAN ("2023-03-01"),
PARTITION `p202303` VALUES LESS THAN ("2023-04-01"),
PARTITION `p202304` VALUES LESS THAN ("2023-05-01"),
PARTITION `p202305` VALUES LESS THAN ("2023-06-01"),
PARTITION `p202306` VALUES LESS THAN ("2023-07-01"),
PARTITION `p202307` VALUES LESS THAN ("2023-08-01"),
PARTITION `p202308` VALUES LESS THAN ("2023-09-01"),
PARTITION `p202309` VALUES LESS THAN ("2023-10-01"),
PARTITION `p202310` VALUES LESS THAN ("2023-11-01"),
PARTITION `p202311` VALUES LESS THAN ("2023-12-01"))