• Resolved betagoo

    (@betagoo)


    I have page with several menus
    All menus are displayed in the same time on every page of website.
    Every menu contains a large number of nodes.
    Every node contains posts from category.
    And the problem is, the Plugin: category-posts-in-custom-menu generate 1200 queries to database.
    Not every time the single page is loading.
    It’s happend for every page of website, but only once per browser session.
    If I visit single page first time, loading time is long, the number of queries is big. When I refresh page F5, the number of queries is about 100, Plugin: category-posts-in-custom-menu generate zero queries.
    I noticed, the plugin generate many update_meta_cache queries.
    Can you helm pe with this problem?

    https://wordpress.org/plugins/category-posts-in-custom-menu/

Viewing 10 replies - 1 through 10 (of 10 total)
  • Hi betagoo,

    thank you for reporting this. As it stands, I have never taken performance into consideration in the plugin; although the plugin enables you to fill a menu up with nothing but categories and posts, it has not been tested with such huge scenarios.

    The plugin will perform one get_posts call per taxonomy that is ‘unfolded’. I will look into it later, to see if I can reduce the number of queries by building one single superquery. For now, there isn’t much I can do for you.

    Question: Those 1200 queries, in what timeframe and how many page requests does this involve? Do you have any idea?

    Kind regards,
    Diana

    I just read up on a few techniques to speed things up, I will look into it for the next version of the plugin. Again, thank you for reporting.

    Kind regards,
    Diana

    Thread Starter betagoo

    (@betagoo)

    If you want test my website, pelase write to me at [Email redacted]
    I will send You full access to my website.
    This is page for test, so You can do everything.

    Andrew Nevins

    (@anevins)

    WCLDN 2018 Contributor | Volunteer support

    @betagoo, Please don’t solicit private support from these forums.

    Thread Starter betagoo

    (@betagoo)

    I don’t need private support.
    I wanted help plugin author.
    I can give him environment for tests.

    Andrew Nevins

    (@anevins)

    WCLDN 2018 Contributor | Volunteer support

    The author is doing their best to support you here on the forums. The question was;

    Those 1200 queries, in what timeframe and how many page requests does this involve? Do you have any idea?

    Thread Starter betagoo

    (@betagoo)

    I can not diagnoze cause of the problem.
    But, problem now is solved.
    I use Transients to cache menu.

    Hi betagoo,

    I indeed read something about Transients. Did you change any code in the plugin to use Transients? (I have never worked with Transients before, tips are welcome 🙂 )

    Kind regards,
    Diana

    Thread Starter betagoo

    (@betagoo)

    I did not modify the plugin.
    In first occurrence of menu I use transients.

    $header_menu_query = get_transient( 'header_menu_query_');
    
    if( $header_menu_query === false )
    {
    
    $header_menu_query = wp_nav_menu( array( 'menu' => $menu_id, 'container' => '', 'items_wrap' => '%3$s', 'echo' => 0 ) );
    
    set_transient( 'header_menu_query_', $header_menu_query, YEAR_IN_SECONDS );
    
    }
    
    echo $header_menu_query;

    Hi betagoo,

    the use of transients was what I wanted to investigate. Thank you for sharing!

    Unfortunately, there is no suitable point in time inside the plugin where I can perform this caching and retrieving (other plugins might edit the menu as well) so this is indeed the best and only option: To cache the entire menu using transients.

    I’ll add it to the plugin FAQ.

    Kind regards,
    Diana

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Performance problem – many database queries’ is closed to new replies.