Last active
March 2, 2018 19:45
-
-
Save andrekeher/8f56413e693ab5bb097afeb156606015 to your computer and use it in GitHub Desktop.
This file contains 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
DELETE | |
FROM wp_posts | |
WHERE post_type = 'revision' | |
AND post_date < NOW() - INTERVAL 90 DAY; | |
DELETE | |
FROM wp_postmeta | |
WHERE post_ID NOT IN (SELECT | |
ID | |
FROM wp_posts); | |
DELETE | |
FROM wp_term_relationships | |
WHERE object_id NOT IN (SELECT | |
ID | |
FROM wp_posts); | |
DELETE | |
FROM wp_comments | |
WHERE comment_post_ID NOT IN (SELECT | |
ID | |
FROM wp_posts); | |
DELETE | |
FROM wp_commentmeta | |
WHERE comment_id NOT IN (SELECT | |
comment_id | |
FROM wp_comments); | |
OPTIMIZE TABLE wp_commentmeta, wp_comments, wp_links, wp_options, wp_postmeta, wp_posts, wp_term_relationships, wp_term_taxonomy, wp_terms, wp_usermeta, wp_users |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment