Site logo

[Resolved] Slow Query: SELECT post_id, meta_key, meta_value

Home Forums Support [Resolved] Slow Query: SELECT post_id, meta_key, meta_value

Home Forums Support Slow Query: SELECT post_id, meta_key, meta_value

Viewing 15 posts - 1 through 15 (of 15 total)
  • Author
    Posts
  • #2104327
    pairfum

    Dear Support,

    Using the Query Monitor plugin we found the following slow query:
    https://i.imgur.com/HYKKjct.png

    This is the url of our staging site:
    https://staging.pairfum.com

    Would you have any suggestions how this can be improved?

    Kind regards,

    Pairfum London

    #2104743
    Fernando
    Customer Support

    Hello Pairfum,

    I tried running Lighthouse on you website and the most significant issue was “initial server response time”.

    See this as reference: https://share.getcloudapp.com/5zunOdA9

    One potential cause for this is a slow server which could in turn be the cause of the slow query.

    See this for reference on things that could cause slow WordPress queries and how to address them: https://www.wpspeedfix.com/speed-up-wordpress-database-queries/

    For this one, can you try contacting your hosting service? Moreover, can you also try doing the steps provided in the link above and see if they could also help?

    Hope this helps! 🙂

    #2104811
    pairfum

    Hi Ferando,

    Many thanks for your advice and recommendations. I very much appreciate it.

    However, we were looking for your advice on how to fix the specific slow query of GeneratePress that we refer to.

    If a slow server was the cause, then it would affect all other queries as well and it doesn’t.

    Hence, we would very much appreciate your advice on how to fix the slow query we refer to in our screenshot.

    Kind regards,

    Pairfum London

    #2104921
    Fernando
    Customer Support

    Considering that your page loads multiple queries, it makes sense that one or two of them would in turn become slow since the page would be trying to communicate with the database server multiple times.

    In terms of this specific query in the screenshot, it would be best to lessen the scope of the query.

    Moreover, it would also be advisable to implement Object Caching, and if possible, lessen the queries implemented in this specific page.

    Here is an article regarding Object Caching: https://wp-rocket.me/blog/object-caching-use-wordpress/#:~:text=I%20Want%20This!-,So%20What%20is%20Object%20Caching%3F,-Object%20caching%20involves

    Hope I was able to answer your inquiry!

    #2105021
    pairfum

    Dear Fernando,

    Many thanks for your reply.

    I have forwarded your suggestion to our hosting company and this is there response:
    Hello,

    Good day to you!

    LiteSpeed lets you use object caching. For most sites on our system object caching doesn’t meaningfully improve performance and it adds complexity, there can be oddities in how the admin works/etc when it is active. Due to this we haven’t enabled object caching by default across all sites.

    We can offer object caching via APCu, however. This works well but is only typically helpful for large/complex e-commerce or membership sites. That can vary and we often at least test-implement it on sites seeing performance problems. But for the average site on our system we don’t see a significant benefit and generally recommend skipping object caching unless there is an issue it is needed to address.

    You can enable APCu via Cpanel–>Select PHP Version–>Select Extensions–>You can select apcu option.

    Feel free to contact us back if you need further assistance.

    Regards

    Reading this reply, it seems to us that Object Cache won’t be the solution.

    Is there nothing that can be done within Generate Press?

    It seems quite odd that this slow query needs to check so many page IDs. Is there something that can be simplified?

    Kind regards,

    Pairfum London

    #2105861
    Tom
    Lead Developer
    Lead Developer

    Hi there,

    It’s hard to tell exactly where that query is coming from looking at the screenshot.

    Does it disappear if you remove the site logo or mobile header logo (if you’re using it?).

    #2107969
    pairfum

    Hi Tom,

    Many thanks for the reply.

    I removed the mobile logo and it does seem to remove one query but the time of the really slow query hasn’t changed much.

    Here are screen shots of the parent theme and PG premium:
    https://i.imgur.com/ay8zWXv.png
    https://i.imgur.com/xdFXbCW.png
    https://i.imgur.com/2RlZLWm.png

    When I also remove the main site logo, the speed of the slow query doesn’t change much:
    https://i.imgur.com/6ia5KmX.png
    https://i.imgur.com/sF0faNS.png
    https://i.imgur.com/bmJqMc8.png

    In other words, it doesn’t look like the site logo is the cause.

    It really is quite surprising how fast the other queries are compared with this one, slow query.

    Many thanks for your continued help with this.

    With kind regards,

    Pairfum London

    #2107987
    pairfum

    Hi Tom,

    We have also tried ‘use navigation as header’ but it does not seem to make any difference to the speed of the query:
    https://i.imgur.com/P5rtHJr.png
    https://i.imgur.com/zeTwh4M.png
    https://i.imgur.com/IU45OUu.png

    With kind regards,

    Pairfum London

    #2108618
    Tom
    Lead Developer
    Lead Developer

    Hi there,

    Looking at the query closer (specifically this screenshot: https://imgur.com/HYKKjct), it looks like the problem query is the generation of your menu items. That would explain all of the IDs (each menu item).

    If you remove your navigation from the page, does the issue go away?

    #2108665
    pairfum

    Hi Tom,

    I temporarily removed the navigation using this guide:
    https://docs.generatepress.com/article/navigation-location/

    As you can see in these screen shots, the problem disappears completely:
    https://i.imgur.com/ClEAOVJ.png
    https://i.imgur.com/yPyWmVo.png

    The slowest query is now the logo. The other queries are amazingly fast.

    Could our Mega Menu be the cause? We use the GP Mega Menu on our site:
    https://docs.generatepress.com/article/building-simple-mega-menu/

    What solution would you suggest?

    Kind regards,

    Pairfum London

    #2108689
    Tom
    Lead Developer
    Lead Developer

    It could be, you’d have to test with and without it to know for sure.

    The WordPress menu system is known for having some performance issues, but it’s not really something you have a ton of control over. There are solutions out there for caching the menu system, but they all have drawbacks.

    The only thing I can suggest is to keep your menu as simple as possible. The more menu items you add the more performance will be affected.

    #2108712
    pairfum

    Hi Tom,

    Many thanks for the explanation and word of caution.

    We only see the number of items growing in our Mega Menu.

    Would a solution be to use a Mega Menu plugin instead, e.g. Max Mega Menu?

    Kind regards,

    Pairfum London

    #2108951
    Tom
    Lead Developer
    Lead Developer

    I doubt that would make a difference unless it doesn’t use the WordPress menu builder.

    This issue is likely something you need to live with unless you build a static (non-dynamic) menu, or find a caching system that doesn’t conflict with the other aspects of your site.

    #2109444
    pairfum

    Many thanks, Tom, for the advice.

    Kind regards,

    Pairfum London

    #2110217
    Tom
    Lead Developer
    Lead Developer

    No problem!

Viewing 15 posts - 1 through 15 (of 15 total)
  • You must be logged in to reply to this topic.