I have a page with many posts and every single page load is noticably slow. Hence, I have checked with Query Monitor the culprit(s) for the slow loading time and found that one query in particular is taking 90% of the time.

This one query is:

FROM posts
WHERE (post_content LIKE '%template=publish%')

This query takes 3-4 seconds everytime a page (frontend/backend) is loaded. This is not userfriendly as well as it puts a straing on the DB, too.

Since this query originates from WP-core, simply deactivating a plugin will not solve the issue. enter image description here

Does anyone have any suggestions as to reduce/improve/cache the query? Unfortunately Object-Caching is not feasable on this site.

Edit: I have clicked the blue button which only shows that it is being called from wp-includes/plugin.php. The button is not for the component part, but for the caller. enter image description here

However, it suggests that a plugin is actually calling it, since it is originated from plugin.php, correct? Any way to trace the culprit plugin?

Edit2: I have done the good ol' deactivate-all-plugins-and-activate-one-by-one-debug-procedure. It turns out, the plugin userpro generates that query. I will contact the author. Let's see what he has to say about that.

  • There must be a lot of entries in posts! Or something else is not quite right. I tried that on an installation with 10k entries and with query cache disabled it took 0.02 seconds in general. One thing you might try is putting a FULLTEXT index on post_content, since there is none by default. But I recommend trying that first on a copy of the database. – maryisdead Jun 4 '19 at 8:45
  • Out of curioisity, as this is totally new to me, if you click on the blue details button, where does the query exactly originate from in the core? I checked couple of my local installs, one with and one without Gutenberg, with Query Monitor > Queries by component > Core, but I didn't notice that kind of query anywhere. What is the function, that is hooked to init and causing that query? – Antti Koskinen Jun 4 '19 at 8:57
  • 2
    This does not look like a core query (do not suggest the outlined text). I would suspect that it was added by one of the plugins or by the theme, but for what purpose? – nmr Jun 4 '19 at 8:58
  • 1
    That’s not a core query. The init hook is core, and that’s where the query is run. That’s all. A plugin or your theme has hooked into unit to run this query. Click the + to trace where it’s actually from. – Jacob Peattie Jun 4 '19 at 10:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.