Created
November 6, 2018 19:25
-
-
Save SQLadmin/f142233b4c91e85a1ad7db7a82fff795 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use sqladmin; | |
DROP PROCEDURE | |
IF EXISTS archive; | |
delimiter // | |
CREATE PROCEDURE | |
archive() | |
begin | |
DECLARE rows INT; | |
DECLARE rows_deleted INT; | |
SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED; | |
SET rows = 1; | |
SET rows_deleted = 10000; | |
WHILE rows > 0 | |
do | |
SET autocommit=1; | |
DELETE | |
FROM test | |
WHERE dop < DATE(Date_sub(Now(), INTERVAL 10 day)) | |
LIMIT 10000; | |
SET rows = row_count(); | |
select sleep(1); | |
commit; | |
END WHILE; | |
END // | |
delimiter ; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment