这块网上咋说都有,到底能不能用到索引???只考虑 5.6 版本以后有 IPC 索引下推的情况
CREATE TABLE `info` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`a` int(11) DEFAULT NULL,
`b` int(11) DEFAULT NULL,
`c` int(11) DEFAULT NULL,
`d` int(11) DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `multi` (`a`,`b`,`c`)
) ENGINE=InnoDB AUTO_INCREMENT=999
select * from info where a = 1 and c = 200
这条 sql 到底能不能用到 c 索引???如果是索引下推的话,到底能不能推到 c 索引,然后减少回表次数
select * from info where a > 1 and b = 200
select * from info where a >= 1 and b = 200
上面两个 sql 都能用到 b 索引么??我觉得是可以的,虽然在 a 在不等值下 b 是无序的,但是索引下推到 b ,能减少回表次数
select * from info where a > 1 and b < 200
select * from info where a >= 1 and b <= 200
我也觉得是能用到 b 索引,理由同上条
select * from info where a > 1 order by b
select * from info where a >= 1 order by b
这个 order by 是回表排序的么
这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。
V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。
V2EX is a community of developers, designers and creative people.