Wordpress Comment Junk

From KOP KB
Jump to: navigation, search

Source: http://www.internetearnings.com/how-to-clean-up-comment-meta-in-wordpress-database/

1.) Clean up “wp_commentmeta” entries which have no relation to wp_comments

Use the following command to look at “junk” entries. It also shows the number of “junk” entries.

SELECT * FROM wp_commentmeta WHERE comment_id
NOT IN (
SELECT comment_id
FROM wp_comments
)

Once satisfied, execute the following command to remove the “junk” entries.

DELETE FROM wp_commentmeta WHERE comment_id
NOT IN (
SELECT comment_id
FROM wp_comments
)

After optimizing the database, the table size drop to ~5MB. 2.) Clean up Akismet related metadata in wp_commentmeta table.

Use the following command to look at “junk” entries. It also shows number of “junk” entries.

SELECT * FROM wp_commentmeta WHERE meta_key
LIKE "%akismet%"

Once satisfied, execute the following command to remove the “junk” entries.

DELETE FROM wp_commentmeta WHERE meta_key
LIKE "%akismet%"