You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
再来看一个常见的面试题:如果有索引 联合索引(a,b,c),查询 a=1 AND c=1 会走索引么?c=1 呢?b=1 AND c=1 呢?
我认为可以增加一个示例,如果是 a = 1 AND c = 1 AND b = 1 的情况下,这个会走索引吗?我在实际的工作中,以为这个只有 a = 1 走了部分索引,实际根据 explain 的执行结果,都走了索引。同理 b = 1 AND c = 1 AND a = 1 也可以走索引,可以看出,只要查询的列在索引中都存在,优化器可以优化这个 where 的查找顺序。