Skip to main content
Fix formatting
Source Link
Elikill58
  • 4.5k
  • 25
  • 29
  • 53

If someone having, "System lock" issues,

   https://shanerutter.co.uk/how-deleted-530-million-records-mysql-database-table/this article

This article will give you better performance.:

BEGIN
    DECLARE incrementValue INT DEFAULT 10000;
    DECLARE curMaxId BIGINT DEFAULT 10000;
    DECLARE maxIdx BIGINT DEFAULT 530000000;
    
    WHILE curMaxId <= maxIdx DO
        DELETE FROM table WHERE id < curMaxId;
        SET curMaxId = curMaxId + incrementValue;
    END WHILE;
END```
CREATE PROCEDURE DeleteLargeData()
BEGIN
    DECLARE incrementValue INT DEFAULT 10000;
    DECLARE curMaxId BIGINT DEFAULT 10000;
    DECLARE maxIdx BIGINT DEFAULT 530000000;
    
    WHILE curMaxId <= maxIdx DO
        DELETE FROM table WHERE id < curMaxId;
        SET curMaxId = curMaxId + incrementValue;
    END WHILE;
END

If someone having, "System lock" issues,

 https://shanerutter.co.uk/how-deleted-530-million-records-mysql-database-table/

This article will give you better performance.

BEGIN
    DECLARE incrementValue INT DEFAULT 10000;
    DECLARE curMaxId BIGINT DEFAULT 10000;
    DECLARE maxIdx BIGINT DEFAULT 530000000;
    
    WHILE curMaxId <= maxIdx DO
        DELETE FROM table WHERE id < curMaxId;
        SET curMaxId = curMaxId + incrementValue;
    END WHILE;
END```

If someone having, "System lock" issues,  this article will give you better performance:

CREATE PROCEDURE DeleteLargeData()
BEGIN
    DECLARE incrementValue INT DEFAULT 10000;
    DECLARE curMaxId BIGINT DEFAULT 10000;
    DECLARE maxIdx BIGINT DEFAULT 530000000;
    
    WHILE curMaxId <= maxIdx DO
        DELETE FROM table WHERE id < curMaxId;
        SET curMaxId = curMaxId + incrementValue;
    END WHILE;
END
Source Link
Jin Lim
  • 2k
  • 1
  • 24
  • 27

If someone having, "System lock" issues,

https://shanerutter.co.uk/how-deleted-530-million-records-mysql-database-table/

This article will give you better performance.

BEGIN
    DECLARE incrementValue INT DEFAULT 10000;
    DECLARE curMaxId BIGINT DEFAULT 10000;
    DECLARE maxIdx BIGINT DEFAULT 530000000;
    
    WHILE curMaxId <= maxIdx DO
        DELETE FROM table WHERE id < curMaxId;
        SET curMaxId = curMaxId + incrementValue;
    END WHILE;
END```