• Resolved mrlukas

    (@mrlukas)


    Using query monitor i found that using Woocommerce on customer order page there are very slow query that takes more then 5 seconds to execute, page load time is arround 10 seconds.

    Query
    SELECT DISTINCT meta_key
    FROM wp_postmeta
    WHERE meta_key NOT BETWEEN ‘_’
    AND ‘_z’
    HAVING meta_key NOT LIKE ‘\\_%’
    ORDER BY meta_key
    LIMIT 30″

    Caller

    1. meta_form()
      wp-admin/includes/template.php:715
    2. post_custom_meta_box()
      wp-admin/includes/meta-boxes.php:826
    3. do_meta_boxes()
      wp-admin/includes/template.php:1443

    How can I fix this issue?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter mrlukas

    (@mrlukas)

    I see this error message in the server error logs. [STDERR] id was called incorrectly. Order properties should not be accessed directly. Backtrace: do_action(‘wp_ajax_woocos_setup_deactivation_form_ajaxPost’), WP_Hook->do_action, WP_Hook->apply_filters, woocos_setup_deactivation_form_ajaxPost, WC_Abstract_Legacy_Order->__get, wc_doing_it_wrong. This message was added in version 3.0.

    Also using this to remove slow query, but page still really slow even I removed it:
    // Removes custom fields in order page
    function remove_custom_order_fields() {
    remove_meta_box(‘postcustom’, ‘shop_order’, ‘normal’);
    }
    add_action(‘add_meta_boxes’, ‘remove_custom_order_fields’, 20);

    Any ideas?

    Plugin Support Shameem R. a11n

    (@shameemreza)

    Hi @mrlukas

    For the slow query, it seems like the query is trying to pull all the distinct meta keys from the wp_postmeta table. The query might be slow due to many rows in the wp_postmeta table. If you have a lot of post metadata, this query can take a while.

    To improve this, you could consider optimizing your database or using a caching plugin to help speed up these types of queries. You could also enable HPOS(WooCommerce > Settings > Advanced > Features > Data storage for orders).

    Regarding the error message, it’s indicating that you’re trying to directly access order properties, which is no longer the correct method since WooCommerce version 3.0. Instead, you should use the provided WooCommerce getter methods. For example, if you were trying to access the order id, instead of using $order->id, you should use $order->get_id(). You’ll need to review your code and replace any direct property accesses with the correct getter methods.

    As for the custom function you’ve used to remove the slow query, it seems to be well written. However, if the page is still slow after removing it, the issue might be related to something else. It could be due to other plugins, your theme, or server configuration. I would recommend deactivating all plugins except WooCommerce to see if the issue persists. If the issue is resolved, reactivate each plugin one by one to identify the culprit. If the issue persists even with all other plugins deactivated, try switching to a default theme like Storefront and see if that helps.

    I hope this helps. If you have any other questions or need further assistance, please don’t hesitate to ask.

    Thanks!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Metakey WordPress core Slow Querie’ is closed to new replies.