欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

delete执行速度优化

程序员文章站 2022-06-08 23:25:50
...

现象:delete子查询非常慢,但select非常快,如下:

select * from test1 where uid in (select uid from test2)-- 非常快

delete from test1 where uid in (select uid from test2)--非常慢

 

改成join表就很快了

delete t1 from test1 t1 inner join test2 t2 on t1.uid=t2.uid