【 TiDB 使用环境】生产环境 & 测试
【 TiDB 版本】V7.5.1
【复现路径】
sql: SELECT * FROM anno WHERE id IN (2306162990490667171,2306162990490667175,2306162990490667170)
explain analyze:
Batch_Point_Get_1 3.00 0 root table:anno time:699.7碌s, loops:1, RU:1.800000, BatchGet:{num_rpc:3, total_time:1.6ms}, tikv_wall_time: 526.6碌s, scan_detail: {total_keys: 3, get_snapshot_time: 52.8碌s, rocksdb: {block: {cache_hit_count: 22}}} handle:[2306162990490667171 2306162990490667175 2306162990490667170], keep order:false, desc:false N/A N/A
【遇到的问题:问题现象及影响】
在ID是主键的情况下:
1、使用该sql无法查询到该有的数据
2、用等于号可以查到
3、用in()的同时,限定分区可以查到
对于分区表,全局索引不生效么?是否有官方文档对此进行了说明?
DDL:
CREATE TABLE annotate
(
id
bigint(20) NOT NULL /*T![auto_rand] AUTO_RANDOM(5) */ COMMENT ‘主键ID’,
task_subject_id
bigint(20) DEFAULT NULL COMMENT ‘题目ID’,
data_id
bigint(20) DEFAULT NULL COMMENT ‘对应数据表id’,
project_id
bigint(20) NOT NULL COMMENT ‘项目ID’,
task_id
bigint(20) DEFAULT NULL COMMENT ‘任务ID’,
data
json NOT NULL COMMENT ‘标注记录’,
operator_id
bigint(20) DEFAULT NULL COMMENT ‘操作员’,
type
tinyint(2) NOT NULL DEFAULT ‘0’ COMMENT ‘结果状态:0 = 标注,1 = 返修(从1开始往后都表示返修)’,
is_delete
tinyint(3) NOT NULL DEFAULT ‘0’ COMMENT ‘逻辑删除’,
create_time
datetime NOT NULL COMMENT ‘创建时间’,
update_time
datetime NOT NULL COMMENT ‘更新时间’,
record_type
tinyint(2) NOT NULL COMMENT ‘结果类型:1 = 全局标签记录,2 = 标注记录 3组框 4跳过’,
feature_id
bigint(20) DEFAULT NULL COMMENT ‘标签ID’,
source_type
tinyint(2) NOT NULL DEFAULT ‘0’ COMMENT ‘来源:0=平台创建,1=导入预标注,2=自动生成标注结果,3=模型生成’,
project_subject_id
bigint(20) DEFAULT NULL COMMENT ‘项目题目ID’,
frame_id
bigint(20) NOT NULL DEFAULT ‘-1’ COMMENT ’ 帧数据id或者任务题目id(题目级结果时存储题目id)',
source_model_id
bigint(20) DEFAULT NULL COMMENT ‘标注结果来源模型版本ID’,
confidence_level
float(4,2) unsigned DEFAULT NULL COMMENT ‘置信度’,
PRIMARY KEY (id
) /*T![clustered_index] CLUSTERED */,
KEY nk_task_subject_id
(task_subject_id
),
KEY nk_project_id
(project_id
),
KEY nk_project_subject_id
(project_subject_id
)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci /*T![auto_rand_base] AUTO_RANDOM_BASE=319981226791556 */
PARTITION BY HASH (project_id
) PARTITIONS 64;