Skip to content

Instantly share code, notes, and snippets.

@phamquocbuu
Created June 16, 2021 14:43
Show Gist options
  • Save phamquocbuu/36f1bc4f5f7cc87a8bf37f14161d7ab4 to your computer and use it in GitHub Desktop.
Save phamquocbuu/36f1bc4f5f7cc87a8bf37f14161d7ab4 to your computer and use it in GitHub Desktop.
Auto repeat delete records in MySQL
DELIMITER $$
CREATE PROCEDURE clean_someTable()
BEGIN
REPEAT
DO SLEEP(1);
DELETE FROM xxx_table where status=2 LIMIT 100000;
UNTIL ROW_COUNT() = 0 END REPEAT;
END$$
DELIMITER ;
-- call clean_someTable();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment