Home  >  Q&A  >  body text

mysql - efficiency issues of inner join and left join

Under what circumstances will the execution efficiency of inner join and left join be relatively high?

学习ing学习ing2674 days ago1771

reply all(2)I'll reply

  • PHP中文网

    PHP中文网2017-06-24 09:43:36

    Left join will not be more efficient than inner join in any scenario, because in addition to the result set of all inner join, left join also needs all the unassociated data in the left table

    In addition to requiring the associated fields to have indexes, left join is best to use a small table as the left table, because the number of retrieval cycles is fewer. The premise is that your business logic is OK, because different writing methods have different logics

    Inner join will automatically select the appropriate table as the base table, and it still requires related field indexes, and it is best to use int type retrieval for higher efficiency

    reply
    0
  • 迷茫

    迷茫2017-06-24 09:43:36

    To be honest, the direction you asked the question is not quite right. . .
    It’s just the restriction conditions and indexes, but the query is reasonable, and the speed is very fast
    inner join is not based on anyone, it displays the data that meets the conditions
    left join is based on the left, and connects the right table

    In terms of efficiency, it is definitely faster to connect a small table to a large table
    Deepen your understanding of the query plan from a MySQL left join optimization example

    reply
    0
  • Cancelreply