Note:
This topic has been translated from a Chinese forum by GPT and might contain errors.Original topic: TiDB集群联合查询慢
[TiDB Usage Environment] Production Environment
[TiDB Version] v6.1.0
[Encountered Problem] TiDB cluster joint query is sometimes fast and sometimes slow
[Reproduction Path] Direct SQL query
[Problem Phenomenon and Impact]
When using a single table query, the response is normal:
SELECT infoid FROM push WHERE userid = 188902 ORDER BY id DESC LIMIT 5
When using a joint database and table query, the response time is between 2 seconds and 60 seconds
SELECT bsp.infoid, dfb.pname FROM base.push bsp
LEFT JOIN global.info dfb ON bsp.infoid = dfb.infoid
WHERE userid = 188902 AND dfb.toptype_code = ‘06’ ORDER BY bsp.date DESC LIMIT 5
Database base table push has 1.3 billion records
CREATE TABLE push
(
id
bigint(20) NOT NULL AUTO_INCREMENT,
userid
int(11) NOT NULL COMMENT ‘User ID’,
infoid
varchar(255) COLLATE utf8mb4_general_ci NOT NULL COMMENT ‘Record ID’,
keys
varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL,
date
bigint(20) NOT NULL,
isvisit
tinyint(4) DEFAULT NULL COMMENT ‘Visited; 0: No 1: Yes’,
isv
tinyint(4) DEFAULT NULL COMMENT,
type
tinyint(4) DEFAULT NULL COMMENT,
PRIMARY KEY (id
),
KEY userid
(userid
),
KEY date
(date
),
KEY infoid
(infoid
)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci
Database global table info has 150 million records
CREATE TABLE dws_f_bid_baseinfo
(
id
bigint(20) unsigned NOT NULL AUTO_INCREMENT,
infoid
varchar(32) NOT NULL COMMENT ‘Data ID’,
a_code
varchar(10) DEFAULT NULL,
c_code
varchar(10) DEFAULT NULL,
d_code
varchar(10) DEFAULT NULL,
yx
decimal(15,4) DEFAULT NULL,
zb
decimal(15,4) DEFAULT NULL,
zk
decimal(10,4) DEFAULT NULL,
names
varchar(500) DEFAULT NULL,
toptype_code
varchar(15) DEFAULT NULL,
s_code
varchar(15) DEFAULT NULL,
pn
varchar(500) DEFAULT NULL,
pc
varchar(100) DEFAULT NULL,
be_code
varchar(15) DEFAULT NULL,
ptime
datetime DEFAULT NULL,
ctime
datetime NOT NULL,
botime
datetime DEFAULT NULL,
isvf
tinyint(1) NOT NULL DEFAULT ‘0’,
ps_id
varchar(100) DEFAULT NULL,
d_id
varchar(45) DEFAULT NULL,
u
varchar(5000) DEFAULT NULL,
p
varchar(2000) DEFAULT NULL,
mp
tinyint(1) NOT NULL DEFAULT ‘0’,
s1
varchar(100) DEFAULT NULL,
uptime
datetime DEFAULT NULL,
crtime
datetime DEFAULT NULL,
br_id
varchar(32) DEFAULT NULL,
ag_id
varchar(32) DEFAULT NULL,
PRIMARY KEY (id
) /T![clustered_index] NONCLUSTERED/,
KEY infoid
(infoid
)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin
[Attachment]
Machine 8*32G, KV storage is SSD disk
Please provide the version information of each component, such as cdc/tikv, which can be obtained by executing cdc version/tikv-server --version.