线上环境
TiDB 5.4
问题及影响:update语句通过主键更新时,explain显示走主键索引,dashboard执行计划却是全表扫描,性能很差
表结构:
CREATE TABLE detail
(
a
bigint(20) NOT NULL DEFAULT ‘0’ COMMENT ‘’,
b
datetime NOT NULL DEFAULT ‘’,
c
datetime NOT NULL DEFAULT ‘’,
d
varchar(100) NOT NULL DEFAULT ‘’ COMMENT ‘’,
e
bigint(20) DEFAULT NULL COMMENT ‘’,
f
tinyint(4) NOT NULL DEFAULT ‘0’ COMMENT ‘’,
g
varchar(100) NOT NULL DEFAULT ‘’ COMMENT ‘’,
…
) PRIMARY KEY (d
,b
,f
,c
,a
,g
) /*T![clustered_index] CLUSTERED */,
UNIQUE KEY index_1
(a
,g
,b
)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT=‘’
PARTITION BY RANGE (TO_DAYS(b
))
( PARTITION p26
VALUES LESS THAN (739282),
PARTITION p27
VALUES LESS THAN (739311),
PARTITION p28
VALUES LESS THAN (739342),
PARTITION p29
VALUES LESS THAN (739372),
PARTITION p30
VALUES LESS THAN (739403),
PARTITION p31
VALUES LESS THAN (739433),
PARTITION p32
VALUES LESS THAN (739464),
PARTITION p33
VALUES LESS THAN (739495),
PARTITION p34
VALUES LESS THAN (739525),
PARTITION p35
VALUES LESS THAN (739556),
PARTITION p36
VALUES LESS THAN (739586),
PARTITION p37
VALUES LESS THAN (739617),
PARTITION p38
VALUES LESS THAN (739648),
PARTITION p39
VALUES LESS THAN (739676)) |
执行SQL:
update detail set status=3, modified=now() where d=‘xxxxx’ and b=‘2024-06-14 14:13:58’ and f=1 and c=‘2024-05-29 07:09:17’ and a=12312432424 and g =‘xxx’ and yn=1 and status!=2 and status!=3;
explain
dashboard