Subqueries vs joins

前端 未结 14 1998
闹比i
闹比i 2020-11-22 16:10

I refactored a slow section of an application we inherited from another company to use an inner join instead of a subquery like:

WHERE id IN (SELECT id FROM          


        
14条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-11-22 16:52

    The subquery was probably executing a "full table scan". In other words, not using the index and returning way too many rows that the Where from the main query were needing to filter out.

    Just a guess without details of course but that's the common situation.

提交回复
热议问题