3

请教一个 MYSQL 联合索引字段顺序的问题

 1 year ago
source link: https://www.v2ex.com/t/920749
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

V2EX  ›  MySQL

请教一个 MYSQL 联合索引字段顺序的问题

  yxjn · 5 小时 15 分钟前 · 606 次点击
请教一个 MySQL 联合索引方案
假设有一个表
table a
column x,y,.....

现在有一个 sql ,select * from a where x = ? and y in (?,?,?,...)

x 的区分度很低,y 的区分度很高。

联合索引是建( x,y )还是( y,x )。

考虑到区分度高索引列在前面的原则似乎是因该是( y,x )。但是考虑到索引下推,似乎又应该是( x,y )?

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK