WordPress custom meta query very slow AND relation
-
My webpage was very slow and I have found out that the reason is this query, which takes between 10 and 20 seconds at least.
function get_car_versions($car_id) { $args = array( 'post_type' => 'version', 'meta_query' => array( 'relation' => 'AND', array( 'key' => '_wpcf_belongs_car_id', 'value' => $car_id, ), 'power-clause' => array( 'key' => 'wpcf-power', 'compare' => 'EXISTS', 'type' => 'numeric', ), 'gear-clause' => array( 'key' => 'wpcf-gear', 'compare' => 'EXISTS', 'type' => 'numeric', ), ), 'orderby' => array( 'power-clause' => 'ASC', 'gear-clause' => 'ASC', ), 'posts_per_page' => -1, ); return get_posts($args); }
Do you see something that can be optimized? Any ideas about the approach I should take? Any help will be appreciated, thank you in advance!
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘WordPress custom meta query very slow AND relation’ is closed to new replies.