Tuesday, 1 August 2017

How to handle large queries in WordPress

Do you sometimes want to see your code fail? Sometimes I write a piece of code and think: it would be much interesting now if this broke, so then I’d have to dig down and find out why. I made an update to Wisdom recently to improve the performance of the reporting. As I’ve been gathering data with the plugin for several months now, the queries are getting far too big. Running a query which includes over 20,000 posts is likely to cause issues with most servers so I started looking for more efficient ways of doing things.
I’d done some research on batch processing WordPress queries and how best to cache or store the results. But before trying anything out, I tried something quick and easy, which I thought might work. Strangely though, as it was loading I found myself hoping that it wouldn’t work. I wanted it to fail. Why?
The answer is that I like tinkering with stuff. For some weird reason, I was actually looking forward to playing around with batch processing so I would be disappointed if my quick and easy method was successful. Watching the spinner on the reload button rotate while the query was running, I knew that if it succeeded I could spend the day doing
Source: https://managewp.org/articles/15758/how-to-handle-large-queries-in-wordpress

source https://williechiu40.wordpress.com/2017/08/01/how-to-handle-large-queries-in-wordpress/

No comments:

Post a Comment