Für die MySql Shell, die counts sind nur informativ:

/* Von akismet als Spam gefundenen Records zählen und löschen */

DELETE FROM wp_commentmeta WHERE meta_key LIKE '%akismet%';
OPTIMIZE TABLE wp_commentmeta;

/* backups - revisions löschen und orphaned records dazu in wp_term_relationships */

DELETE FROM wp_posts WHERE post_type = "revision";
DELETE FROM wp_term_relationships 
WHERE NOT EXISTS ( SELECT * FROM wp_posts WHERE wp_term_relationships.object_id = wp_posts.ID );
OPTIMIZE TABLE wp_posts;
OPTIMIZE TABLE wp_term_relationships;


/* wp_postmeta */ 

DELETE FROM wp_postmeta pm LEFT JOIN wp_posts wp ON wp.ID = pm.post_id WHERE wp.ID IS NULL;
OPTIMIZE TABLE wp_postmeta;


/* spam comments */

DELETE FROM wp_comments WHERE wp_comments.comment_approved = 'spam';
OPTIMIZE TABLE wp_comments;

/* orphaned objects */

DELETE FROM wp_options WHERE option_name LIKE '_transient_%';
OPTIMIZE TABLE wp_comments;

/* Fuer woocommerce ! */

DELETE FROM wp_options WHERE option_name LIKE '_wc_session_%' OR option_name LIKE '_wc_session_expires_%';
OPTIMIZE TABLE  wp_options;