How can I speed up MySQL query with multiple joins

前端 未结 7 1569
再見小時候
再見小時候 2021-02-07 11:25

Here is my issue, I am selecting and doing multiple joins to get the correct items...it pulls in a fair amount of rows, above 100,000. This query takes more than 5mins when the

7条回答
  •  Happy的楠姐
    2021-02-07 12:07

    Make sure your date columns and all the columns you are joining on are indexed.

    Doing an unequivalence operator on your dates means it checks every row, which is inherently slower than an equivalence.

    Also, using DISTINCT adds an extra comparison to the logic that your optimizer is running behind the scenes. Eliminate that if possible.

提交回复
热议问题