• Resolved reeper6868

    (@reeper6868)


    Hi,
    I am having a slow query from Woocommerce using Query Monitor. This happens on the dashboard page in admin. I am using Health Check & Troubleshooting plugin. Have disabled every plugin except Woocommerce and am on a default Twenty Twenty theme in troubleshooting mode. Below is the data show on Query Monitor:

    `SELECT wp_typosts.ID
    FROM wp_typosts
    LEFT JOIN wp_tyterm_relationships
    ON (wp_typosts.ID = wp_tyterm_relationships.object_id)
    INNER JOIN wp_typostmeta
    ON ( wp_typosts.ID = wp_typostmeta.post_id )
    WHERE 1=1
    AND ( wp_tyterm_relationships.term_taxonomy_id IN (2,3,4,5) )
    AND ( ( wp_typostmeta.meta_key = ‘_virtual’
    AND wp_typostmeta.meta_value = ‘no’ ) )
    AND wp_typosts.post_type = ‘product’
    AND ((wp_typosts.post_status = ‘publish’
    OR wp_typosts.post_status = ‘draft’
    OR wp_typosts.post_status = ‘pending’
    OR wp_typosts.post_status = ‘private’))
    GROUP BY wp_typosts.ID
    ORDER BY wp_typosts.post_date DESC
    LIMIT 0, 1`

    Caller: WP_Query->get_posts()

    WP_Query->get_posts()
    wp-includes/class-wp-query.php:3129
    WP_Query->query()
    wp-includes/class-wp-query.php:3586
    WP_Query->__construct()
    wp-includes/class-wp-query.php:3718
    WC_Product_Data_Store_CPT->query()
    wp-content/plugins/woocommerce/includes/data-stores/class-wc-product-data-store-cpt.php:2042
    WC_Data_Store->__call()
    wp-content/plugins/woocommerce/includes/class-wc-data-store.php:207
    WC_Product_Query->get_products()
    wp-content/plugins/woocommerce/includes/class-wc-product-query.php:76
    wc_get_products()
    wp-content/plugins/woocommerce/includes/wc-product-functions.php:48
    Automattic\W\A\F\O\T\Shipping::has_physical_products()
    wp-content/plugins/woocommerce/src/Admin/Features/OnboardingTasks/Tasks/Shipping.php:114
    Automattic\W\A\F\O\T\Shipping->can_view()
    wp-content/plugins/woocommerce/src/Admin/Features/OnboardingTasks/Tasks/Shipping.php:78
    Automattic\W\A\F\O\TaskList->Automattic\W\A\F\O\{closure}()
    wp-content/plugins/woocommerce/src/Admin/Features/OnboardingTasks/TaskList.php:299
    array_filter()
    wp-content/plugins/woocommerce/src/Admin/Features/OnboardingTasks/TaskList.php:299
    Automattic\W\A\F\O\TaskList->get_viewable_tasks()
    wp-content/plugins/woocommerce/src/Admin/Features/OnboardingTasks/TaskList.php:300
    Automattic\W\A\F\O\TaskList->is_complete()
    wp-content/plugins/woocommerce/src/Admin/Features/OnboardingTasks/TaskList.php:230
    WC_Admin_Dashboard_Setup->should_display_widget()
    wp-content/plugins/woocommerce/includes/admin/class-wc-admin-dashboard-setup.php:190
    WC_Admin_Dashboard_Setup->__construct()
    wp-content/plugins/woocommerce/includes/admin/class-wc-admin-dashboard-setup.php:50
    WC_Admin->conditional_includes()
    wp-content/plugins/woocommerce/includes/admin/class-wc-admin.php:102
    do_action('current_screen')
    wp-includes/plugin.php:476
    WP_Screen->set_current_screen()
    wp-admin/includes/class-wp-screen.php:422
    set_current_screen()
    wp-admin/includes/screen.php:243

    Component woocommerce
    Time 0.2387s

    The current version of Woocommerce 6.7.0
    Please let me know why the slow query? Is there also a fix for this? We were also wondering if this is related to high CPU spikes with admin-ajax.php and index.php on our servers as the front end does not display linkage to the mentioned file.
    Thanks in advance

    • This topic was modified 2 years, 7 months ago by reeper6868.
Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Support con

    (@conschneider)

    Engineer

    Hi there!

    I am having a slow query from Woocommerce using Query Monitor.
    Component woocommerce
    Time 0.2387s

    Query Monitor is more for optimizing queries. I would say that your time of 0.2387s looks pretty normal to me.

    Please let me know why the slow query?

    The stack trace seems to suggest that this could be the setup wizard. What are you trying to do when you see that query?

    > We were also wondering if this is related to high CPU spikes with admin-ajax.php and index.php on our servers as the front end does not display linkage to the mentioned file.

    It could be but cpu spikes are more common for complex tasks i.e. the server running a scheduled backup job.

    You might also have a scaling problem. How big is your site?

    Kind regards,

    Thread Starter reeper6868

    (@reeper6868)

    Hi @conschneider,
    Thanks for getting back to me.

    The stack trace seems to suggest that this could be the setup wizard. What are you trying to do when you see that query?

    Nothing is being done or being setup. This is seen on the Dashboard page after logging on to admin.
    We have been trying to diagnose high admin-ajax.php CPU load on our server. Though it does not show up on google tools or GTMetrix. This spikes as our site is loaded causing a lag load of more than 5secs affecting our page speed insights. Tested on staging environment on localhost the page load times goes down when woocommerce is disabled and the query appears only when enabled.

    You might also have a scaling problem. How big is your site?

    Our site is pretty large with lots of products and images. You can check it out here

    • This reply was modified 2 years, 7 months ago by reeper6868.
    Thread Starter reeper6868

    (@reeper6868)

    Would you also be able to point me in the direction of how to diagnose this problem? Any help would be much appreciated.
    Kind Regards,

    Plugin Support con

    (@conschneider)

    Engineer

    Hi there,

    Though it does not show up on google tools or GTMetrix. This spikes as our site is loaded causing a lag load of more than 5secs affecting our page speed insights.

    CPU spikes don’t tell you much in terms of performance. You can evaluate them if a specific process fails to run (i.e. a sync job keeps terminating). In terms of loading time I would instead check everything with your browser – tools like GTmetrix etc are in my opinion designed to highlight every little loading byte, but don’t help much.

    I can see you have a cache, but it does nothing in terms of deferring the loading.
    https://a.cl.ly/12uLmEJk

    What kind of cache are you using? Me I would go with something server sided: https://blog.martinfjordvald.com/implementing-full-page-caching-with-nginx-and-php/ or look for a plugin that tries to defer loading of assets.

    Kind regards,

    Thread Starter reeper6868

    (@reeper6868)

    Hi again,

    What kind of cache are you using? Me I would go with something server sided: https://blog.martinfjordvald.com/implementing-full-page-caching-with-nginx-and-php/ or look for a plugin that tries to defer loading of assets.

    We had WPOptimize before and decided to test with WPRocket instead. Currently that is the plugin activated with heartbeat enabled as well.

    What kind of cache are you using? Me I would go with something server sided: https://blog.martinfjordvald.com/implementing-full-page-caching-with-nginx-and-php/ or look for a plugin that tries to defer loading of assets.

    Would you be able to recommend what plugin? Will installing memcache and redis help with this spike? We just confirmed our host supports.

    • This reply was modified 2 years, 7 months ago by reeper6868.
    Plugin Support con

    (@conschneider)

    Engineer

    Hi there,

    > Would you be able to recommend what plugin?

    I also had good experiences with WP-Optimize, though it took a while to get the correct settings (and – I think – the pro version)

    > Will installing memcache and redis help with this spike? We just confirmed our host supports.

    Yes, that should make a difference. Here is some background additionally: https://spinupwp.com/doc/caching-in-spinupwp/

    You might need this then: https://www.ads-software.com/plugins/redis-cache/

    Kind regards,

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘WP_Query->get_posts() Slow Query on Dashboard’ is closed to new replies.