• Hi, thanks for the great plugin.

    We are experiencing a spike in visitors on a particular woocommerce installation and the DB seems to be the slow part. I enabled MariaDB slow quey log for 1 hour and screened the log file and this query pops up thousands of times (although very small time to process each, but too many for the period):

    SELECT
    ID
    FROM
    wp_yith_wcwl_lists
    WHERE
    session_id = ‘?’
    AND expiration > NOW()
    AND is_default = ?

    I am not sure if it is this the problem, but in 1 hour period this query was called 60165 times using 1191 seconds in total. Meaning a almost 1/3 of the time processing this kind of request only.

    We use Woocommerce 4.1 and YITH wishlist plugin 3.0.10 on flatsome theme with the heart icon on the menu bar along with cart, I am guessing it is firing in every page load possibly multiple times? No idea.

    We noticied slow admin after 200 concurrent users (according to google analytics) shopping and 100% CPU usage after 250+, again, not sure if related but since we troubleshooting and found this many queries made me wonder and i came here to ask. All this happened after we updated woocommerce (was very old 3.4) and everythign else like theme and plugins.

    Also, there is this on PHP error.log, not sure if related:

    PHP message: wc_get_product was called incorrectly. wc_get_product should not be called before woocommerce_init, woocommerce_after_register_taxonomy e woocommerce_after_register_post_type are done.
    Backtrace: require_once(‘wp-load.php’), require_once(‘/MYDOMAIN.COM/wp-config.php’), require_once(‘wp-settings.php’), do_action(‘init’), WP_Hook->do_action, WP_Hook->apply_filters, YITH_WCWL_Frontend->init, YITH_WCWL_Frontend->_convert_cookies_to_session, YITH_WCWL_Wishlist->save, YITH_WCWL_Wishlist->save_items, WC_Data->save, WC_Data_Store->create, YITH_WCWL_Wishlist_Item_Data_Store->create, YITH_WCWL_Wishlist_Item->get_product_price, YITH_WCWL_Wishlist_Item->get_product, wc_get_product, wc_doing_it_wrong. This message was added in version 3.9″ while reading response header from upstream, client: [ip-censored], server: MYDOMAIN.COM, request: “GET /wp-admin/admin-ajax.php?action=flatsome_update_wishlist_count HTTP/2.0”, upstream: “fastcgi://127.0.0.1:9070”

    Again, I am not sure if it really is the plugin, since the front end functionality is ok. Any help appreciated.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author YITHEMES

    (@yithemes)

    Hi there Fabio

    Thank you for your report
    That query is used to retrieve default wishlist for current guest user
    This is unfortunately performed once per visit, but should be called only one time per page load, since result is cached upon first execution, and future access to default wishlist uses cache value

    Could the high number of queries perormed be related to a spike in your visits, or bots accessing your site?
    May I suggest to temporarly disable Add to Wishlist for guest users?

    If you’re running latest version of the plugin I could suggest a snippet in order to remove button for guests only

    Regarding the error that you’ve found, it seems related to some function invoked by your theme, so I suggest you to contact Theme’s support team about that

    Thread Starter Fabio Oliveira

    (@fabio-oliveira)

    Hi, thank you for replying. Please send me the snippet so I can check, I was considering disabling the wishlist function temporarily to check if it helps, but it is such a handy function that I am against disabling it. Also after like 8h of huge traffic spike things got back to normal so I am not really getting that slow anymore.

    I will contact the Flatsome theme support, thank you.

    Plugin Author YITHEMES

    (@yithemes)

    Hi again Fabio

    Please, try adding the following snippet of code at the end of functions.php file of your theme or child

    if ( ! function_exists( 'yith_wcwl_remove_add_to_wishlist_for_guests' ) ) {
    	function yith_wcwl_remove_add_to_wishlist_for_guests( $show ) {
    		if ( ! is_user_logged_in() ) {
    			return false;
    		}
    
    		return $show;
    	}
    	add_filter( 'yith_wcwl_show_add_to_wishlist', 'yith_wcwl_remove_add_to_wishlist_for_guests' );
    }
    
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Lots of queries to the DB’ is closed to new replies.