reduxframework / redux-framework

Redux is a simple, truly extensible options framework for WordPress themes and plugins!
http://redux.io
Other
1.73k stars 583 forks source link

Using data Argument in field cause slow database queires #4020

Closed Nikanadv closed 1 month ago

Nikanadv commented 1 month ago

I am using redux framework in my custom wordpress theme for theme options. I am using data Argument to retrive products for a select field and this cause slow query issue. this is my field:

array( 'id' => 'test_select', 'type' => 'select', 'data' => 'posts', 'args' => array( 'post_type' => 'product', 'posts_per_page' => -1, 'orderby' => 'title', 'order' => 'ASC', ), 'multi' => true, )

and in site frontend there is an slow query reported by query monitor plugin:

update_meta_cache update_postmeta_cache update_post_caches WP_Query->get_posts WP_Query->query get_posts Redux_WordPress_Data->get_data Redux_WordPress_Data->get Redux_Options_Defaults->field_default_values Redux_Options_Defaults->default_values Redux::set_defaults Redux::load_redux Redux::create_redux do_action('after_setup_theme') require_once('wp-settings.php') require_once('wp-config.php') require_once('wp-load.php') require('wp-blog-header.php')

when i remove select field there is no slow query. Why get posts in theme options run in frontend?!

kprovance commented 1 month ago

I can't say without knowing your particular setup. The posting instructions were very specific about the required information, but that was not included. Sorry. Any select field with hundreds or thousands of items will drag a system. It's why the select field has an ajax load feature: https://devs.redux.io/core-fields/select.html