Force MySQL to use two indexes on a Join

前端 未结 2 506
攒了一身酷
攒了一身酷 2021-02-05 11:48

I am trying to force MySQL to use two indexes. I am joining a table and I want to utilize the cross between the two indexes. The specific term is Using intersect and here is a l

2条回答
  •  清酒与你
    2021-02-05 12:47

    MySQL only supports using a single index per join. If you want it to utilize two columns as indices in the join, you should create a single index over those two columns. Note that this isn't as bad as it seems, because an index over (a,b) doubles as an index over just a.

    See the MySQL manual

    MySQL cannot use an index if the columns do not form a leftmost prefix of the index.

提交回复
热议问题