• Hi,

    My WooCommerce page is very slow as there is some slow queries being triggered.

    I am not able to fix this class function as it is taking more than 4 seconds just to calculate count.

    Backtrace:
    WP_Posts_List_Table->__construct
    _get_list_table

    Query

    SELECT COUNT( 1 )
    FROM wp_posts
    WHERE post_type = 'shop_order'
    AND post_status NOT IN ( 'trash','auto-draft','inherit','request-pending','request-confirmed','request-failed','request-completed','dp-rewrite-republish' )
    AND post_author = 1

    Time Taken by this Query: 4.1015 Seconds

    I have done optimisation with this wordpress query but I am not able to override the above function.

    Optimised Query
    SELECT?SUM(temp.num_posts)?as?total?FROM?(SELECT?post_status,?COUNT(?*?)?AS?num_posts?FROM?wp_posts?WHERE?post_type?=?'shop_order'?AND?post_status?=?"wc-cancelled"?UNION?ALL?SELECT?post_status,?COUNT(?*?)?AS?num_posts?FROM?wp_posts?WHERE?post_type?=?'shop_order'?AND?post_status?=?"wc-completed"?UNION?ALL?SELECT?post_status,?COUNT(?*?)?AS?num_posts?FROM?wp_posts?WHERE?post_type?=?'shop_order'?AND?post_status?=?"wc-pending"?UNION?ALL?SELECT?post_status,?COUNT(?*?)?AS?num_posts?FROM?wp_posts?WHERE?post_type?=?'shop_order'?AND?post_status?=?"wc-on-hold"?UNION?ALL?SELECT?post_status,?COUNT(?*?)?AS?num_posts?FROM?wp_posts?WHERE?post_type?=?'shop_order'?AND?post_status?=?"wc-refunded")?as?temp

    Time Taken by this Query: 950ms Seconds

    Time taken is way better than what we already have with wordpress, Is there a way to override this function and optimise it according to above query.

    The page I need help with: [log in to see the link]

Viewing 7 replies - 1 through 7 (of 7 total)
  • The right place to ask WooCommerce support is on there support page – https://www.ads-software.com/support/plugin/woocommerce/

    Thread Starter Sanchit Varshney

    (@sanchitvarshney)

    But WP_Posts_List_Table class belongs to WordPress and function (_get_list_table) being called through wordpress on edit.php by default. @alanfuller

    If you can help with this function, then it would be very helpful for me. As my website has over 100Gb of Data and this count query is making Orders Table so slow. Basically It’s WordPress Posts as Orders are basically WordPress Posts.

    Have you tried adding indexes on post_author and post_statuses? No idea if that will help.

    You can of course just write your own view by extending WP_List_Table and hide the default one and not have any counts.

    Thread Starter Sanchit Varshney

    (@sanchitvarshney)

    I have like 3 Million Orders on the website and this function keep getting triggered. It’s inside /wp-admin/edit.php at line no. 47. Whenever the WP_Posts_List_Table initialises and check for the count with the above query I mentioned which takes like 4seconds.

    Thread Starter Sanchit Varshney

    (@sanchitvarshney)

    post_status and post_author is already an index on DB

    If you have 3 million orders I have to admit I’m surprised you are seeking free advise from an open forum.

    I can read code too and yes WP_Posts_List_Table constructor performs a count of posts so they can be displayed in the table header links.

    As I mentioned, one solution is to write your own display of list of orders without counts – it isn’t very hard.

    Good luck with your search for a solution.

    Thread Starter Sanchit Varshney

    (@sanchitvarshney)

    Thanks for the solution, I am thinking the same to create a custom list class.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘_get_list_table taking 4 seconds to load’ is closed to new replies.