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
Copy file name to clipboardexpand all lines: docs/mysql/index.md
+8-1
Original file line number
Diff line number
Diff line change
@@ -26,6 +26,10 @@ CREATE TABLE `table` (
26
26
```
27
27
4.组合索引(将多个列组合在一起创建索引)
28
28
29
+
***mysql执行查询中,只会使用到一个索引***
30
+
>最左前缀:意思是使用组合索引的时候,从左到右依次匹配,否则不会使用组合索引。
31
+
例如`ALTER TABLE people ADD INDEX lname_fname_age (lame,fname,age); `其实我们是建立了三个索引,分别是:单列索引lame,组合索引(lame,fname),组合索引(lame,fname,age),mysql索引的时候只会使用其中一个索引。所以创建组合索引的时候,尽量把使用频繁的放在左边
0 commit comments