Remove WordPress database bloat including orphaned postmeta rows, unlimited post revisions, expired transients, and spam comments with safe SQL queries and WP-CLI commands.
Turn on the MySQL slow query log, set the right threshold, and use mysqldumpslow and pt-query-digest to find and fix the queries slowing down WordPress.