Also you should use .htaccess to BLOCK some user agents that are well knows to scrape and attack.
If you want, i can expand on this.
Why are the queries taking so long? And how can I fix the problem? I am also getting lots of warnings from my host saying i am running out of memory, when it really shouldn't be the case.... It has been happening for a while and i was hoping the new wordpress update would fix it, but it hasn't....
Any suggestions? It took over 80 seconds for this page ot load. Usually it is done in half a second
Yes, this function could work slow if there are not indexed data in a large datable. Sometimes MySQL tables need to be optimized and re-indexed. We're currently working on this part of the forum to make such functions work very fast. The update comes this week, so please wait for it.
No code will fix an issue that we don't know from what comes from.
For example a FAST scraper or an attacker, probing 100+ times per seconds.....
@percysgrowroom It would be very useful to install somekind of realtime visitors viewer, so you can see what is going on on your site.
Also Wordfence has a RATE LIMITER that will help you find our the offenders. Wordfence Realtime Traffic (for ALL traffic) is telling you what is happening. You need to sit down for some hours and monitor what is going on..... Who is doing what ....
But mind you, Wordfence is heavy ... You may need to uninstall it after findings. After 1-2 days.
AND if you decide to use it, DISABLE the SCAN OPTION, DEFINITELY.