wp_dashboard_recent_comments() has very bad performance with lots of spam
|Reported by:||joehoyle||Owned by:|
The way wp_dashboard_recent_comments() loops the comments is very inefficient. This is because it gets comments 50 at a time, fills the recent commnts array, and fetches another 50 if the array was not filled (due to comments being spam etc), fetches another 50.. and so on.
I recently had an issue with a site that had 5000 spam comments _in front_ of any approved comments, this took about 20+ seconds to load the dashboard. The fix it seems is simple: specify the approves status in the mysql query instead - not sure why this was never done.
I have attached a patch for this.