admin管理员组

文章数量:1291092

I'm building a query on a custom post type and some custom post meta.
Here is the query :

$meta_query = array(
            'relation' => 'AND',
            array(
                'key' => '_thumbnail_id'
            ),
            array(
                'key' => 'offre_economie',
                'value' => 'pending',
                'compare' => '!='
            ),
            array(
                'key' => 'offre_app_partenaire',
                'value' => 1,
                'compare' => '!='
            ),
            array(
                'relation' => 'OR',
                array(
                    'key' => 'offre_expiration',
                    'value' => '',
                    'compare' => '='
                ),
                array(
                    'key' => 'offre_expiration',
                    'value' => date('Ymd'),
                    'compare' => '>=',
                    'type' => 'DATE'
                )
            ),
            array(
                'relation' => 'OR',
                array(
                    'key' => 'offre_fin_evenement',
                    'value' => date('Ymd'),
                    'compare' => '>=',
                    'type' => 'DATE'
                ),
                array(
                    'key' => 'offre_fin_evenement',
                    'value' => 'null',
                    'compare' => 'NOT EXISTS'
                ),
                array(
                    'key' => 'offre_fin_evenement',
                    'value' => '',
                    'compare' => '='
                )
            )
        );
        $query->set('meta_query', $meta_query);

It works perfectly fine on our testing site but when I put this last part on the final site :

array(
    'relation' => 'OR',
    array(
        'key' => 'offre_fin_evenement',
        'value' => date('Ymd'),
        'compare' => '>=',
        'type' => 'DATE'
    ),
    array(
        'key' => 'offre_fin_evenement',
        'value' => 'null',
        'compare' => 'NOT EXISTS'
    ),
    array(
        'key' => 'offre_fin_evenement',
        'value' => '',
        'compare' => '='
    )
)

When loading additional pages the query is so slow and sometimes it doesn't even load.
I've found some info on this question Meta query terribly slow. But I still can't figure out why it works well on the testing site and not on the final one.

本文标签: Custom Meta Query doesn39t work the same on two site