当前位置:Gxlcms > 数据库问题 > 数据库优化技巧之in和not in

数据库优化技巧之in和not in

时间:2021-07-01 10:21:17 帮助过:41人阅读

select * from table1 where table1.id not in(select id from table2)

这样的写法尽管看起来非常直观。可是运行的效率会非常低下,在数据量非常大的时候效果尤其明显,我们推荐使用not exists或左连接来取代。

select a.* from table1 a left join table2 b on a.id=b.id where b.id is null

相同。这样的方法也适用于in

数据库优化技巧之in和not in

标签:select   rac   mod   sts   sql语句   优化   适用于   语句   exist   

人气教程排行