Hi
I would need some more details about your site to be sure (eg. number of posts, average daily visitors, etc.) but I bet the problem lies here:
SELECT p.ID AS id, p.post_title AS title, p.post_author AS uid FROM jmu_popularpostssummary v LEFT JOIN jmu_posts p ON v.postid = p.ID WHERE 1 = 1 AND p.post_type IN(‘post’, ‘page’) AND p.ID NOT IN(6513, 6655, 1579) AND v.view_datetime > DATE_SUB(‘2018-01-04 16:20:18’, INTERVAL 365 DAY) AND p.post_password = ” AND p.post_status = ‘publish’ GROUP BY v.postid ORDER BY SUM(v.pageviews) DESC LIMIT 20 OFFSET 0;
You’re having WPP try to retrieve an entire year of data from your database.
If:
- WPP has been running on your site for some time now,
- You have a lot of posts,
- You get a lot of visits everyday
… chances are your database server can’t handle that and crashes when your site is at its peak hours (specially if your site is on a shared hosting), which would explain the “database connection error” message you’re seeing sometimes.
So:
- If you want to keep your “best posts from the past year” list, make sure you cache the result so WPP doesn’t run such a heavy query so often. This doesn’t guarantee that your database server won’t suffer during peak hours but it should be a lot better.
- Install a caching plugin to reduce the load on your server.
- If your server has memcached installed and enabled and you’re using W3 Total Cache (or any other caching plugin that supports memcached), consider installing a memcached plugin to further improve the performance of your site.
- Read the Performance section from the wiki.
Hi Héctor,
Thanks for the valuable info. You are right – we have lots of posts and a large number of visits every day, and WPP has been running on our blog for almost 4 years.
I will try your advice and make sure to set WPP for best performance (i.e. enable caching, log limit, data sampling) and see how it goes.
Thanks again!
Thanks for the valuable info. You are right – we have lots of posts and a large number of visits every day, and WPP has been running on our blog for almost 4 years.
Don’t mention it, and thanks for being such a loyal user 🙂
I will try your advice and make sure to set WPP for best performance (i.e. enable caching, log limit, data sampling) and see how it goes.
I recommend starting with the caching part only. Try the rest of the features if/when needed.
If you have any other questions, don’t hesitate to ask 🙂