Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

in 慢查询问题 #703

Closed
bs7729 opened this issue May 19, 2022 · 1 comment
Closed

in 慢查询问题 #703

bs7729 opened this issue May 19, 2022 · 1 comment

Comments

@bs7729
Copy link

bs7729 commented May 19, 2022

CREATE TABLE IF NOT EXISTS node.travelrecord_qq (
id bigint NOT NULL AUTO_INCREMENT,
user_id varchar(100) DEFAULT NULL,
traveldate date DEFAULT NULL,
fee decimal(10, 0) DEFAULT NULL,
days int DEFAULT NULL,
blob longblob,
PRIMARY KEY (id),
KEY id (id),
KEY dex_user_id (user_id)
) ENGINE = InnoDB CHARSET = utf8
DBPARTITION BY mod_hash(user_id) DBPARTITIONS 10
TBPARTITION BY mod_hash(id) TBPARTITIONS 2;

用user_id做为分库

SELECT COUNT(1) from travelrecord_qq WHERE user_id in(28)
SELECT COUNT(1) from travelrecord_qq WHERE user_id in(18);
方式查询快

SELECT COUNT(1) from travelrecord_qq WHERE user_id in(18,28);
in里多个值后查询很慢

查询对比如下:
Q0~2E`)LF}RH@ U7X{LUH

in有多个值时,用explain查看,把所有库与所有库都用union all 连接了

image

junwen12221 added a commit that referenced this issue May 19, 2022
@junwen12221
Copy link
Collaborator

http://dl.mycat.org.cn/2.0/1.22-release/mycat2-1.22-release-jar-with-dependencies-2022-5-19.jar

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants