Search code examples
mysqlsqlstored-proceduresrollback

Kill Mysql query without rolling back changes


I have a query/stored procedure that has been running for a long time now and I noticed a small error in the updates it is doing. The error isn't anything major and is easily fixable but I was wondering if I could stop the query WITHOUT rolling back the changes already made and then run it again with the fixed procedure.


Solution

  • If your MySQL requires you to commit changes, then unfortunately, killing a query means that it will be rolled back.

    This is not true for MyISAM tables, as everything you do on that table will be committed at once.

    This is also not true for procedures. If you have 5 Queries in a procedure and four have already run and been committed (via explicit commit or because autocommit is enabled), then these 4 queries will not be rolled back.