请教这条 mysql 优化出路在哪?

2020-06-24 16:17:12 +08:00
 demonps

表结构

create table assign_idx(
  it_id BIGINT UNSIGNED NOT NULL,
  cat_id BIGINT UNSIGNED NOT NULL,
  c_type BIGINT UNSIGNED NOT NULL,
  c_user_id BIGINT UNSIGNED NOT NULL DEFAULT 0,
  l_user_id BIGINT UNSIGNED NOT NULL DEFAULT 0,
  create_time BIGINT UNSIGNED NOT NULL,
  PRIMARY KEY(it_id),
  INDEX idx_c_type_cat_c_user_time(c_type, cat_id, c_user_id, create_time)
) ENGINE=InnoDB ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=4 default charset utf8mb4;
explain select it_id from assign_idx where c_user_id = 0 and l_user_id != 3333 and (c_type, cat_id) in ((30, 1), (30, 2), (30, 3), (20, 4), (20, 6), (20, 9), (20, 10)) order by create_time asc limit 1;

explain 结果 总有 filesort 如何破

2635 次点击
所在节点    程序员
21 条回复
demonps
2020-06-25 20:05:24 +08:00
@zhangysh1995 试了好多方法 是 in 的锅 目前 in 不太好再抽一个量表示 蛋疼中~

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/684483

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX