Query Loop Spiking CPU?

I ran into an issue where editing the homepage would spike CPU to 6.0. I have a feeling it’s Query Block using up php resources?

Web host has tested on their end by disabling all plugins and themes and also came to the conclusion that GB is causing the cpu spike.

For what it’s worth, when adding a Parameter of “Include Posts” inside Query Loop also show the thinking process. Sometimes all posts will lost and sometimes the loading is endless. I noticed another user posted this issue on another thread. I wonder if it’s a server resource issue.

Editing a homepage with 3 Query Blocks is causing this spike. Do you think this is the cause and how can we try and resolve this?

Thanks!

Ian

The Query Loop block uses the core WP_Query feature: WP_Query | Class | WordPress Developer Resources

Having three queries on a page definitely shouldn’t create a CPU spike. It could be a combination of your query parameters, or even a combination of them and another plugin.

You’ll need to debug by removing other plugins/tweaking your query parameters to try to find the offending configuration.

Thanks for chiming in. The web host disabled all plugins and diagnosed it was GB. I think they saw 10 dB calls or something from those Query Loops I presume. The site does have over 1000 posts so maybe having to sift through and pull from there is too much for this server type. It more than likely is the web host limiting resources as well.

Some WP_Query args will definitely be more resource-intensive than others, especially if there are a lot of posts.

You can always test by adding your own custom WP_Query functions to a shortcode or custom template to see if it’s something within the args (completely separate to GB).

I am having the same issue. Is it possible to limit the max number of posts previewed from 50 to, say 10-12, in each query loop?

@gauravtiwari we will introduce a filter in 1.7 to allow you to overwrite the default cap of 50 posts in the editor.

2 Likes

Just wondering, what’s the ETA for 1.7.0?

Will enter public testing in the upcoming weeks, the release date is not confirmed yet.