I have a wordpress website up and running that is reasonably popular but over the last couple of days my performance has degraded terribly.
I have installed Jet Profiler and have been monitoring the MySQL database to see if I can find something wrong and this one query is consistently the worst offender.
SELECT SQL_CALC_FOUND_ROWS wp_posts.* FROM wp_posts WHERE 1=1 AND wp_posts.post_type = 'post' AND (wp_posts.post_status = 'publish') ORDER BY wp_posts.ID ASC LIMIT 0, 1
My first guess would be to remove the SQL_CALC_FOUND_ROWS function and change the * to be specific fields only but I can’t find what is calling this query.
How would I find out which php file is calling this?
There’s a good chance that’s your front page. I assume you’ve installed caching in front of WordPress, either using WP Super Cache or something else (nginx, Squid, etc). If not, you shouldn’t be looking at the database. Caching is critical for WP.
You might want to take a look at these two issues posted on their tracker:
http://core.trac.wordpress.org/ticket/10469
http://core.trac.wordpress.org/ticket/12557
(Update: Added a link)
The final solution was that a plug in called TDO Mini Forms was badly coded and destroying my database.
So if you ever have this problem and have that plug in I strongly recommend removing it. It doesn’t appear to even exist as a valid option in the plugin database anymore