SQL Advanced Subquery Optimization

in 与 exists

indexed

  1. inner joinIt is best to use when there is an index , next in, existsworst

no index

  • The small table drives the large table, because jointhe method requires distinct, no index distinctconsumes a lot of performance
    • So exists has the best performance, followed by in, and join has the worst performance.
  • Large tables drive small tables
    • The performance of in and exists should be close, both are worse, and exists is slightly better, exceeding 5%.
    • But it's much faster inner joinbecause of usingjoin buffer

Guess you like

Origin blog.csdn.net/youhebuke225/article/details/130941297