Overview
SQL queries and tips to remove revisions, transients, and orphaned data from WordPress.
Originally published on Jang Keyte's Blog.
This article covers Clean Up Redundant Data in WordPress Database — practical notes from real-world web development experience.
Code Examples
DELETE FROM eot3utvmj_commentmeta WHERE comment_id NOT IN (SELECT comment_id FROM eot3utvmj_comments);
DELETE FROM eot3utvmj_commentmeta WHERE meta_key LIKE '%akismet%';
DELETE FROM eot3utvmj_postmeta WHERE meta_key = "_edit_lock";
DELETE FROM eot3utvmj_postmeta WHERE meta_key = "_edit_last";
DELETE FROM eot3utvmj_options WHERE option_name LIKE ('%\_transient\_%');
Read More
For the full Vietnamese version, switch language using the VI | EN toggle above, or visit the original post.
Chọn xóa dữ liệu comment
DELETE FROM eot3utvmj_commentmeta WHERE comment_id NOT IN (SELECT comment_id FROM eot3utvmj_comments);
DELETE FROM eot3utvmj_commentmeta WHERE meta_key LIKE '%akismet%';
Chọn xóa dữ liệu post_meta
DELETE FROM eot3utvmj_postmeta WHERE meta_key = "_edit_lock";
DELETE FROM eot3utvmj_postmeta WHERE meta_key = "_edit_last";
Chọn xóa dữ liệu options:
DELETE FROM eot3utvmj_options WHERE option_name LIKE ('%\_transient\_%');
Nếu bị spam contact từ flamingo của Contact Form 7 thì thực hiện xóa thêm
DELETE FROM eot3utvmj_posts WHERE post_status="flamingo_spam";
DELETE FROM eot3utvmj_posts WHERE post_type="flamingo_inbound";
DELETE FROM eot3utvmj_posts WHERE post_type="flamingo_contact";
DELETE FROM eot3utvmj_postmeta WHERE meta_key="_field_ten-khach-hang";
DELETE FROM eot3utvmj_postmeta WHERE meta_key="_field_so-dien-thoai";
DELETE FROM eot3utvmj_postmeta WHERE meta_key="_field_noi-dung";
DELETE FROM eot3utvmj_postmeta WHERE meta_key="_from";
DELETE FROM eot3utvmj_postmeta WHERE meta_key="_from_email";
DELETE FROM eot3utvmj_postmeta WHERE meta_key="_from_name";
DELETE FROM eot3utvmj_postmeta WHERE meta_key="_subject";
Thanks for reading!