Meta Box plugin call un-needed query ?

Support General Meta Box plugin call un-needed query ?Resolved

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #10998
    kesitkesit
    Participant

    Hi,
    I have a performance problem in my website. Right now I'm finding a clue which can cause it.

    I'm using Query Monitor and find that in every page, Meta Box plugin is querying one of my custom post type (which has about 2000 posts). I don't know what the relevancy of this query run for, but it started from 'init' function of meta-box plugin.

    Would you mind to give me a clue how can I find out the way to minimize or probably erase this query?

    Here is the query:

    SELECT xxxxxx_posts.*
    FROM xxxxxx_posts 
    WHERE 1=1 
    AND xxxxxx_posts.post_type = 'my_cpt'
    AND ((xxxxxx_posts.post_status = 'publish')) 
    ORDER BY xxxxxx_posts.post_date DESC

    Below is the caller:

    do_action('init')
    wp-includes/plugin.php:453
    RWMB_Core->register_meta_boxes()
    wp-content/plugins/meta-box/inc/core.php:54
    rwmb_get_meta_box()
    wp-content/plugins/meta-box/inc/functions.php:281
    RW_Meta_Box->__construct()
    wp-content/plugins/meta-box/inc/meta-box.php:60
    RW_Meta_Box::normalize_fields()
    wp-content/plugins/meta-box/inc/meta-box.php:383
    RWMB_Field::call()
    wp-content/plugins/meta-box/inc/field.php:613
    RWMB_Post_Field::normalize()
    wp-content/plugins/meta-box/inc/fields/post.php:46
    RWMB_Post_Field::query()
    wp-content/plugins/meta-box/inc/fields/post.php:74
    WP_Query->__construct()
    wp-includes/class-wp-query.php:3336
    WP_Query->query()
    wp-includes/class-wp-query.php:3230
    WP_Query->get_posts()
    wp-includes/class-wp-query.php:2831
    #11033
    digitaalitoimistodigitaalitoimisto
    Participant

    Noticed this as well, I've got >60k posts :S

    It seems that the 'post' field, that allows selection of a post, metabox will query all available options for the field on every request. I think it should query available options only when the actual meta box field is being rendered.

    I'm not using metabox frontend functions so I was able to narrow this problem to dashboard only by not registering metaboxes on the frontend requests.

    #11035
    Anh TranAnh Tran
    Keymaster

    Hello,

    Thanks a lot for your reporting! I've noticed the problem, too and will fix it today!

    #11050
    kesitkesit
    Participant

    I am also not using Meta Box frontend functions. So I put this code

    if(is_admin()) {
        add_filter( 'rwmb_meta_boxes', 'myfunc_register_meta_boxes' );
    }
    

    But the query still happened on frontend... is my code wrong?

    #11051
    Anh TranAnh Tran
    Keymaster

    Hey guys, I've just pushed 2 commits to fix this problem on Github. Could you please try it and let me know the result?

    Thanks,
    Anh

    #11055
    kesitkesit
    Participant

    Hi Anh,
    thanks for your Github push.

    I'm currently trying it and it seems that no more un-needed query anymore. But still trying this and that to see if it's impacting something else.

    But thanks a lot for your response

    Best regards,
    kesit

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.