---
title: "Discussion on \"索引优化原则\" | Hashnode"
description: "Discussion on \"索引优化原则\". 最左前缀匹配原则\n\n\n联合索引，mysql会从做向右匹配直到遇到范围查询(>、<、between、like)就停止匹配，比如a = 1 and b = 2 and c > 3 and d = 4 如果建立(a,b,c,d)顺序的索引，d是用不到索引的，如果建立(a,b,d,c)的索引则都可以用到，a,b,d的顺序可以任意调整\n\n\n=和in可以乱序，比如a = 1 and b = 2 and c = 3 建立(a,b,c)索引可以任意顺序，mysql的查询优化器会帮你优化成索引可以识别的形式\n\n索..."
url: "https://hashnode.com/posts/57si5byv5lyy5yyw5y6f5yiz/658e752b8b992c4a306b0dc5"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [索引优化原则](https://blog.robinjiang.com/57si5byv5lyy5yyw5y6f5yiz?utm_source=hashnode&utm_medium=feed)

最左前缀匹配原则 联合索引，mysql会从做向右匹配直到遇到范围查询(>、<、between、like)就停止匹配，比如a = 1 and b = 2 and c > 3 and d = 4 如果建立(a,b,c,d)顺序的索引，d是用不到索引的，如果建立(a,b,d,c)的索引则都可以用到，a,b,d的顺序可以任意调整 =和in可以乱序，比如a = 1 and b = 2 and c = 3 建立(a,b,c)索引可以任意顺序，mysql的查询优化器会帮你优化成索引可以识别的形式 索...

Jan 13, 2016 · 1 min read · blog.robinjiang.com  
Read the article

## Written by

[robin Jiang](https://hashnode.com/@robinj)

@robinj · SHENZHEN,CN

  
[View profile](https://hashnode.com/@robinj)

Geek,Agile

## Responses

Markdown supported · ⌘↵ to post

No responses yet.
