最好附上执行计划.如果在ab表上都有co11,2,3,4的索引的话,
这种写法应该是很快的了.

解决方案 »

  1.   

    不会有更快的写法了吧?!
    为什么不考虑索引?对这个sql太重要了!
      

  2.   

    delete a
    where (col1,col2,col3,col4) in (
    select col1,col2,col3,col4 from b
    where exists(select 1 from a where col1=b.col1 and col2=b.col2 and col3=b.col3 and col4=b.col4)
    )//对a表建立索引(col1,col2,col3,col4)
      

  3.   

    学习,学习。
    俺从来都不考虑速度,汗ing
      

  4.   

    信息不全面阿
    说得仔细点
    表关系什么的
    exists in严重影响速度
      

  5.   

    信息不全面阿
    说得仔细点
    表关系什么的
    exists in严重影响速度
      

  6.   

    快速删除表中记录!!!
    TRUNCATE TABLE 表名
    TRUNCATE TABLE  a
    where exists
    (select 1 from b where a.col1=b.col1 and a.col2=b.col2 and a.col3=b.col3 and a.col4=b.col4)
      

  7.   

    TRUNCATE 快速地从一个表中删除所有行。它和无条件的 DELETE 有同样的效果,不过因为它不做表扫描,因而快得多。在大表上最有效。
      

  8.   

    DELETE FROM a
    WHERE exists 
    (SELECT l FROM b 
    WHERE (b.coll, b.col2, b.col3, b.col4) = any 
    (SELECT a.col1, a.col2, a.col3, a.col4 FROM a);
    供参考。
      

  9.   

    delete from a where 1 = (select distinct 1 from b where a.col1=b.col1 and a.col2=b.col2 and a.col3=b.col3 and a.col4=b.col4)//exits,not ,in等,最好就少用了:)