CREATE OR REPLACE PROCEDURE Mem_Test_main(p_batch_size INT) BEGIN DECLARE i INT DEFAULT 0; DECLARE id CHAR(9); DECLARE batch_count INT DEFAULT 0; PREPARE stmt FROM 'UPDATE mem_test SET `ts`=NOW() WHERE `id`=?'; -- Start the transaction START TRANSACTION; WHILE i <= 9999999 DO -- Generate the ID based on the current value of i SET id = LPAD(i, 8, '0'); SET id = CONCAT('A', id); -- Execute the prepared statement with the current ID EXECUTE stmt USING id; -- Increment counters SET i = i + 1; SET batch_count = batch_count + 1; -- Commit the transaction after every batch IF batch_count = p_batch_size THEN COMMIT; START TRANSACTION; -- Restart transaction for next batch SET batch_count = 0; -- Reset the batch count END IF; END WHILE; -- Final commit after the loop ends COMMIT; -- Deallocate the prepared statement DEALLOCATE PREPARE stmt; END