Create a gist now

Instantly share code, notes, and snippets.

@jdevalk /DB-cleanup.sql Secret
Created Dec 17, 2013

Embed
DELETE FROM wp_postmeta WHERE meta_key = '_yoast_wpseo_meta-robots' AND meta_value = 'index,follow';
DELETE FROM wp_postmeta WHERE meta_key = '_yoast_wpseo_meta-robots-noindex' AND meta_value = '0';
DELETE FROM wp_postmeta WHERE meta_key = '_yoast_wpseo_meta-robots-nofollow' AND meta_value = '0';
DELETE FROM wp_postmeta WHERE meta_key = '_yoast_wpseo_meta-robots-adv' AND meta_value = 'none';
DELETE FROM wp_postmeta WHERE meta_key = '_yoast_wpseo_meta-robots-adv' AND meta_value = '';
DELETE FROM wp_postmeta WHERE meta_key = '_yoast_wpseo_sitemap-prio' AND meta_value = '-';
DELETE FROM wp_postmeta WHERE meta_key = '_yoast_wpseo_sitemap-include' AND meta_value = '-';
DELETE FROM wp_postmeta WHERE meta_key = '_yoast_wpseo_opengraph-description' AND meta_value = '';
DELETE FROM wp_postmeta WHERE meta_key = '_yoast_wpseo_google-plus-description' AND meta_value = '';
DELETE FROM wp_postmeta WHERE meta_key = '_yoast_wpseo_title' AND meta_value = '';
DELETE FROM wp_postmeta WHERE meta_key = '_yoast_wpseo_metadesc' AND meta_value = '';
DELETE FROM wp_postmeta WHERE meta_key = '_yoast_wpseo_metakeywords' AND meta_value = '';
DELETE FROM wp_postmeta WHERE meta_key = '_yoast_wpseo_focuskw' AND meta_value = '';
DELETE FROM wp_postmeta WHERE meta_key = '_yoast_wpseo_bctitle' AND meta_value = '';
DELETE FROM wp_postmeta WHERE meta_key = '_yoast_wpseo_canonical' AND meta_value = '';
DELETE FROM wp_postmeta WHERE meta_key = '_yoast_wpseo_redirect' AND meta_value = '';
DELETE FROM wp_postmeta WHERE meta_key = '_wpseo_video_meta' AND meta_value = '';
DELETE FROM wp_postmeta WHERE meta_key = '_yoast_wpseo_video_meta' AND meta_value = 'none';
DELETE FROM wp_postmeta WHERE meta_key = '_yoast_wpseo_linkdex' AND meta_value = '0';
DELETE FROM wp_postmeta WHERE meta_key = '_yoast_wpseo_newssitemap-original' AND meta_value = '';
DELETE FROM wp_postmeta WHERE meta_key = '_yoast_wpseo_newssitemap-stocktickers' AND meta_value = '';
DELETE FROM wp_postmeta WHERE meta_key = '_yoast_wpseo_sitemap-html-include' AND meta_value = '-';
DELETE FROM wp_postmeta WHERE meta_key = '_yoast_wpseo_opengraph-image' AND meta_value = '';
DELETE FROM wp_postmeta WHERE meta_key = '_yoast_wpseo_videositemap-tags' AND meta_value = '';
DELETE FROM wp_postmeta WHERE meta_key = '_yoast_wpseo_videositemap-category' AND meta_value = '';
DELETE FROM wp_postmeta WHERE meta_key = '_yoast_wpseo_videositemap-rating' AND meta_value = '';
DELETE FROM wp_postmeta WHERE meta_key = '_yoast_wpseo_videositemap-thumbnail' AND meta_value = '';
@archon810

This comment has been minimized.

Show comment
Hide comment
@archon810

archon810 Jan 5, 2014

If you want to see what the value are first as well as how many there are, before deleting them:

SELECT * FROM wp_postmeta WHERE meta_key = '_yoast_wpseo_meta-robots' AND meta_value = 'index,follow'
UNION
SELECT * FROM wp_postmeta WHERE meta_key = '_yoast_wpseo_meta-robots-noindex' AND meta_value = '0'
UNION
SELECT * FROM wp_postmeta WHERE meta_key = '_yoast_wpseo_meta-robots-nofollow' AND meta_value = '0'
UNION
SELECT * FROM wp_postmeta WHERE meta_key = '_yoast_wpseo_meta-robots-adv' AND meta_value = 'none'
UNION
SELECT * FROM wp_postmeta WHERE meta_key = '_yoast_wpseo_meta-robots-adv' AND meta_value = ''
UNION
SELECT * FROM wp_postmeta WHERE meta_key = '_yoast_wpseo_sitemap-prio' AND meta_value = '-'
UNION
SELECT * FROM wp_postmeta WHERE meta_key = '_yoast_wpseo_sitemap-include' AND meta_value = '-'
UNION
SELECT * FROM wp_postmeta WHERE meta_key = '_yoast_wpseo_opengraph-description' AND meta_value = ''
UNION
SELECT * FROM wp_postmeta WHERE meta_key = '_yoast_wpseo_google-plus-description' AND meta_value = ''
UNION
SELECT * FROM wp_postmeta WHERE meta_key = '_yoast_wpseo_title' AND meta_value = ''
UNION
SELECT * FROM wp_postmeta WHERE meta_key = '_yoast_wpseo_metadesc' AND meta_value = ''
UNION
SELECT * FROM wp_postmeta WHERE meta_key = '_yoast_wpseo_metakeywords' AND meta_value = ''
UNION
SELECT * FROM wp_postmeta WHERE meta_key = '_yoast_wpseo_focuskw' AND meta_value = ''
UNION
SELECT * FROM wp_postmeta WHERE meta_key = '_yoast_wpseo_bctitle' AND meta_value = ''
UNION
SELECT * FROM wp_postmeta WHERE meta_key = '_yoast_wpseo_canonical' AND meta_value = ''
UNION
SELECT * FROM wp_postmeta WHERE meta_key = '_yoast_wpseo_redirect' AND meta_value = ''
UNION
SELECT * FROM wp_postmeta WHERE meta_key = '_wpseo_video_meta' AND meta_value = ''
UNION
SELECT * FROM wp_postmeta WHERE meta_key = '_yoast_wpseo_video_meta' AND meta_value = 'none'
UNION
SELECT * FROM wp_postmeta WHERE meta_key = '_yoast_wpseo_linkdex' AND meta_value = '0'
UNION
SELECT * FROM wp_postmeta WHERE meta_key = '_yoast_wpseo_newssitemap-original' AND meta_value = ''
UNION
SELECT * FROM wp_postmeta WHERE meta_key = '_yoast_wpseo_newssitemap-stocktickers' AND meta_value = ''
UNION
SELECT * FROM wp_postmeta WHERE meta_key = '_yoast_wpseo_sitemap-html-include' AND meta_value = '-'
UNION
SELECT * FROM wp_postmeta WHERE meta_key = '_yoast_wpseo_opengraph-image' AND meta_value = ''
UNION
SELECT * FROM wp_postmeta WHERE meta_key = '_yoast_wpseo_videositemap-tags' AND meta_value = ''
UNION
SELECT * FROM wp_postmeta WHERE meta_key = '_yoast_wpseo_videositemap-category' AND meta_value = ''
UNION
SELECT * FROM wp_postmeta WHERE meta_key = '_yoast_wpseo_videositemap-rating' AND meta_value = ''
UNION
SELECT * FROM wp_postmeta WHERE meta_key = '_yoast_wpseo_videositemap-thumbnail' AND meta_value = ''

If you want to see what the value are first as well as how many there are, before deleting them:

SELECT * FROM wp_postmeta WHERE meta_key = '_yoast_wpseo_meta-robots' AND meta_value = 'index,follow'
UNION
SELECT * FROM wp_postmeta WHERE meta_key = '_yoast_wpseo_meta-robots-noindex' AND meta_value = '0'
UNION
SELECT * FROM wp_postmeta WHERE meta_key = '_yoast_wpseo_meta-robots-nofollow' AND meta_value = '0'
UNION
SELECT * FROM wp_postmeta WHERE meta_key = '_yoast_wpseo_meta-robots-adv' AND meta_value = 'none'
UNION
SELECT * FROM wp_postmeta WHERE meta_key = '_yoast_wpseo_meta-robots-adv' AND meta_value = ''
UNION
SELECT * FROM wp_postmeta WHERE meta_key = '_yoast_wpseo_sitemap-prio' AND meta_value = '-'
UNION
SELECT * FROM wp_postmeta WHERE meta_key = '_yoast_wpseo_sitemap-include' AND meta_value = '-'
UNION
SELECT * FROM wp_postmeta WHERE meta_key = '_yoast_wpseo_opengraph-description' AND meta_value = ''
UNION
SELECT * FROM wp_postmeta WHERE meta_key = '_yoast_wpseo_google-plus-description' AND meta_value = ''
UNION
SELECT * FROM wp_postmeta WHERE meta_key = '_yoast_wpseo_title' AND meta_value = ''
UNION
SELECT * FROM wp_postmeta WHERE meta_key = '_yoast_wpseo_metadesc' AND meta_value = ''
UNION
SELECT * FROM wp_postmeta WHERE meta_key = '_yoast_wpseo_metakeywords' AND meta_value = ''
UNION
SELECT * FROM wp_postmeta WHERE meta_key = '_yoast_wpseo_focuskw' AND meta_value = ''
UNION
SELECT * FROM wp_postmeta WHERE meta_key = '_yoast_wpseo_bctitle' AND meta_value = ''
UNION
SELECT * FROM wp_postmeta WHERE meta_key = '_yoast_wpseo_canonical' AND meta_value = ''
UNION
SELECT * FROM wp_postmeta WHERE meta_key = '_yoast_wpseo_redirect' AND meta_value = ''
UNION
SELECT * FROM wp_postmeta WHERE meta_key = '_wpseo_video_meta' AND meta_value = ''
UNION
SELECT * FROM wp_postmeta WHERE meta_key = '_yoast_wpseo_video_meta' AND meta_value = 'none'
UNION
SELECT * FROM wp_postmeta WHERE meta_key = '_yoast_wpseo_linkdex' AND meta_value = '0'
UNION
SELECT * FROM wp_postmeta WHERE meta_key = '_yoast_wpseo_newssitemap-original' AND meta_value = ''
UNION
SELECT * FROM wp_postmeta WHERE meta_key = '_yoast_wpseo_newssitemap-stocktickers' AND meta_value = ''
UNION
SELECT * FROM wp_postmeta WHERE meta_key = '_yoast_wpseo_sitemap-html-include' AND meta_value = '-'
UNION
SELECT * FROM wp_postmeta WHERE meta_key = '_yoast_wpseo_opengraph-image' AND meta_value = ''
UNION
SELECT * FROM wp_postmeta WHERE meta_key = '_yoast_wpseo_videositemap-tags' AND meta_value = ''
UNION
SELECT * FROM wp_postmeta WHERE meta_key = '_yoast_wpseo_videositemap-category' AND meta_value = ''
UNION
SELECT * FROM wp_postmeta WHERE meta_key = '_yoast_wpseo_videositemap-rating' AND meta_value = ''
UNION
SELECT * FROM wp_postmeta WHERE meta_key = '_yoast_wpseo_videositemap-thumbnail' AND meta_value = ''
@osaunier

This comment has been minimized.

Show comment
Hide comment
@osaunier

osaunier Mar 16, 2015

Hi,
That's what I need but using it, it crash my WPML plugin, maybe there's an updated script?
Thanks

Hi,
That's what I need but using it, it crash my WPML plugin, maybe there's an updated script?
Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment