我试图从性能方面了解哪种方法更好:
查询1:
SELECT * FROM table1
WHERE col1 NOT IN(SELECT col1 FROM table2)
Run Code Online (Sandbox Code Playgroud)
查询2:
SELECT * FROM table1
LEFT JOIN table2 ON table1.col1 = table2.col1
WHERE table2.col1 IS NULL
Run Code Online (Sandbox Code Playgroud)
第一个查询使用DEPENDENT SUBQUERY
,第二个查询仅使用索引。