Meta Box plugin call un-needed query ?
- This topic has 5 replies, 3 voices, and was last updated 7 years, 2 months ago by kesit. 
- 
		AuthorPosts
- 
		
			
				
August 14, 2018 at 11:46 AM #10998kesit ParticipantHi, 
 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 DESCBelow 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:2831August 17, 2018 at 2:53 PM #11033digitaalitoimisto ParticipantNoticed 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. August 17, 2018 at 5:38 PM #11035Anh Tran KeymasterHello, Thanks a lot for your reporting! I've noticed the problem, too and will fix it today! August 18, 2018 at 1:02 PM #11050kesit ParticipantI 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? August 18, 2018 at 2:57 PM #11051Anh Tran KeymasterHey 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, 
 AnhAugust 19, 2018 at 9:02 PM #11055kesit ParticipantHi 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
- 
		AuthorPosts
- You must be logged in to reply to this topic.