Delete statement in SQL is very slow

前端 未结 15 694
自闭症患者
自闭症患者 2020-12-22 23:23

I have statements like this that are timing out:

DELETE FROM [table] WHERE [COL] IN ( \'1\', \'2\', \'6\', \'12\', \'24\', \'7\', \'3\', \'5\')
15条回答
  •  失恋的感觉
    2020-12-22 23:54

    In my case the database statistics had become corrupt. The statement

    delete from tablename where col1 = 'v1' 
    

    was taking 30 seconds even though there were no matching records but

    delete from tablename where col1 = 'rubbish'
    

    ran instantly

    running

    update statistics tablename
    

    fixed the issue

提交回复
热议问题