Last active
October 23, 2019 14:23
-
-
Save ivanweiler/d119a84da790ea2a5cff80db113777b0 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
DROP PROCEDURE IF EXISTS ClearCoreUrlTable; | |
DELIMITER $$ | |
CREATE PROCEDURE `ClearCoreUrlTable`() | |
BEGIN | |
SET @delete_counter = 0; | |
SET @table_name = 'core_url_rewrite'; | |
SET @total_records = (SELECT count(*) FROM core_url_rewrite WHERE product_id is not null and category_id is not null); | |
WHILE @delete_counter < @total_records DO | |
SET @varSQL = CONCAT('DELETE FROM ', @table_name,' WHERE category_id IS NOT NULL and product_id IS NOT NULL AND is_system=0 LIMIT 500;'); | |
PREPARE stmt FROM @varSQL; | |
EXECUTE stmt; | |
DEALLOCATE PREPARE stmt; | |
SET @delete_counter = @delete_counter + 500; | |
END WHILE; | |
END $$ | |
DELIMITER ; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment