Custom Fields
Re-Envisioned
Support General Meta Box plugin call un-needed query ?

This topic contains 5 replies, has 3 voices, and was last updated by  kesit 1 year, 1 month ago.

  • Creator
    Topic
  • #10998
    Resolved
    kesit
    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
Viewing 5 replies - 1 through 5 (of 5 total)
  • Author
    Replies
  • #11033

    digitaalitoimisto
    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 Tran
    Keymaster

    Hello,

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

    #11050

    kesit
    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 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

    kesit
    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 5 replies - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.