Skip to content

Instantly share code, notes, and snippets.

@yanknudtskov
Last active August 28, 2019 12:25
Show Gist options
  • Save yanknudtskov/904ffa37596f1aeca1a9534387822e03 to your computer and use it in GitHub Desktop.
Save yanknudtskov/904ffa37596f1aeca1a9534387822e03 to your computer and use it in GitHub Desktop.
Cleaning out WordPress Database in relation to very large comments table
DELETE FROM wp_postmeta
WHERE post_id IN (
SELECT ID from wp_posts WHERE post_title = 'sfn_followup_emails'
);
DELETE FROM wp_posts WHERE post_title = 'sfn_followup_emails';
DELETE FROM wp_postmeta
WHERE post_id IN (
SELECT ID from wp_posts WHERE post_title = 'wcs_report_update_cache' and post_status != 'pending'
);
DELETE FROM wp_posts WHERE post_title = 'wcs_report_update_cache' and post_status != 'pending';
DELETE FROM wp_postmeta
WHERE post_id IN (
SELECT ID from wp_posts WHERE post_title = 'wcs_report_update_cache' and post_status != 'pending'
);
DELETE FROM wp_posts WHERE post_title = 'wcs_report_update_cache' and post_status != 'pending';
DELETE FROM wp_postmeta
WHERE post_id IN (
SELECT ID from wp_posts WHERE post_title = 'woo_sc_generate_coupon_csv' and post_status != 'pending'
);
DELETE FROM wp_posts WHERE post_title = 'woo_sc_generate_coupon_csv' and post_status != 'pending';
DELETE FROM wp_postmeta
WHERE post_id IN (
SELECT ID from wp_posts WHERE post_title = 'woo_sc_import_coupons_from_csv' and post_status != 'pending'
);
DELETE FROM wp_posts WHERE post_title = 'woo_sc_import_coupons_from_csv' and post_status != 'pending';
DELETE FROM wp_postmeta
WHERE post_id IN (
SELECT ID from wp_posts WHERE post_title = 'sfn_send_usage_report' and post_status != 'pending'
);
DELETE FROM wp_posts WHERE post_title = 'sfn_send_usage_report' and post_status != 'pending';
DELETE FROM wp_comments
WHERE comment_type = 'action_log';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment