I needed to delete 20.000+ rows in the wp_postmeta table which related to a Custom Post Type and Yoast SEO. The SQL I ended up using was this:
DELETE pm FROM wp_postmeta pm LEFT JOIN wp_posts wp ON wp.ID = pm.post_id WHERE wp.post_type LIKE '%CUSTOMPOSTTYPENAME%' AND pm.meta_key LIKE '%_yoast_%'
IMPORTANT: Don’t try this at home. And backup your database! I’m not responsible for any case of data loss!