Very slow query in WordPress

0

My website is very slow and I have seen that it is due to the following query, which takes between 10 and 20 seconds and I still do not know why.

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);
}

I'm pretty desperate with this, do you see anything weird? Something that can be optimized? any ideas? all help is welcome.

    
asked by dACEvid 17.07.2018 в 16:25
source

0 answers