Tracking down the origins of slow SQL code in WordPress

I’ve been optimising a WP All Import job for a client with 600,000 products and while doing so I was hitting refresh on SHOW FULL PROCESSLIST to catch queries which take too long to run. I kept seeing the following query: SELECT status, COUNT( * ) FROM wp_posts WHERE post_type = ‘product’ GROUP BY post_status; […]