Just floating ideas,
Could you not use a category or categories filter and a random selection from a smaller dataset?
Or add a date filter so the random posts are within two dates, some older posts may not be as relevent as newer ones?
HTH
David
I have one idea that would work conceptually but have never implemented cron jobs so don’t ask for more specific information! 🙂 But if it worked you could still use the FULL set of posts and not have to filter them down first..
Your problem stems from the fact that you are querying a very large posts table upon every homepage load. To remedy this you could do the query ONCE every hour or 30 mins etc. and store the results in a custom WordPress table, or preferably, the options table (as you should only create new tables if absolutely necessary).
Now the hard bit, how do you do that? Well you could look into cron jobs, see here for more information:
http://wpguru.co.uk/2009/02/how-to-setup-a-cron-job/
These work by repeating an action on your server at specific time intervals. So, if you could get it to call a php script to generate the results of your query every so often and store it somewhere, then upon every home page load you would simply need to read in this data and not have to query hundreds of thousands of posts for EVERY load/refresh of your home page.
Hope this gives you something to think about. Perhaps someone with more experience of cron jobs could give you further help.
Thread Starter
gward1
(@gward1)
I like that idea dgwyer, I’ll have to look more into Cron Jobs, it’s been forever since I’ve used them. I could implement this on my categories page too as they are going slow as well.
I keep meaning to take a look at cron jobs, just never seem to find the time to dig in and have a play. 🙂