I have a website that operates similarly to many freelancing websites where people can make bids. Its become painfully slow in recent weeks and I used query monitor to find out the issue is likely over 140,000 posts that were build up over the last 5 years. Below is a query that takes 36 seconds (from query monitor) ...
SELECT wp_4_posts.ID
FROM wp_4_posts
WHERE 1=1
AND wp_4_posts.post_parent = 427941
AND wp_4_posts.post_author IN (1)
AND wp_4_posts.post_type = 'bid'
AND ((wp_4_posts.post_status = 'publish'))
ORDER BY wp_4_posts.post_date DESC
LIMIT 0, 5 +
WP_Query->get_posts()
...
I'm wondering how I can:
- Delete any post of type "bid" that are in draft status
- Delete any post of type "bid" that are in published status but made before 2020