需要删除数据的表A,需删除大概200W条数据,其中where条件涉及到其他表,我的语句如下
delete from A where A.id in (select id from B where 条件1 and 条件2 and 条件3)
这样很慢,因为A表中有300W条记录 过滤条件中有200W条记录。求教有没有其他方式,我想用表连接 但是delete语句中好像没法实现。

解决方案 »

  1.   

    条件1 and 条件2 and 条件3:内容是什么
    delete a from A 
    inner join
    (select id from B where 条件1 and 条件2 and 条件3) c
    on A.id=c.id
      

  2.   

    delete  from smg_logl a
     inner join
     (select mbr_cid from smg_t ) c
     on a.mt=c.mbr_cid
    这是我的语句
      

  3.   

    delete  from smg_logl a
      inner join
      (select mbr_cid from smg_t ) c
      on a.mt=c.mbr_cid
     这是我的语句 
      

  4.   

    仔细看看1楼的代码
    delete  a from smg_logl a
       inner join
       (select mbr_cid from smg_t ) c
       on a.mt=c.mbr_cid
      

  5.   

    thanks very much,虽然看的不太懂,但是确实能用,并且效率提高了好多
      

  6.   

    delete A from A,B
     where A.id=B.id and B.条件1 and B.条件2 and B.条件3