Support

Account

Home Forums General Issues Query ACF too slow

Helping

Query ACF too slow

  • Hello i have problem query ACF too slow.
    Scenario :
    I have custom posttype :
    1. Club (id, CLUB NAME)
    2. Match (home_club, goal_home, competition, away_club, goal_away)
    3. competition (Id, competition name)

    I try show head to head CLUB A VS Club B, so i will show all match ( Club A as home and Club B as away ) AND (Club A as away and club B as home). I use this query argument, but time to load 6s.

    $type = 'match';
    $args = array(
        'post_type' => $type,
        'posts_per_page' => '5',
        'post_status' => 'publish',
        'meta_query' => array(
            array(
                'relation' => 'AND',
                array(
                    'key' => 'home_club',
                    'value' => $home[1],
                    'compare' => '='
                ),
                array(
                    'key' => 'club_away',
                    'value' => $away[1],
                    'compare' => '='
                ), array(
                    'key' => 'is_finish',
                    'value' => true,
                    'compare' => '='
                )
            ),
            'relation' => 'OR',
            array(
                'relation' => 'AND',
                array(
                    'key' => 'home_club',
                    'value' => $away[1],
                    'compare' => '='
                ),
                array(
                    'key' => 'club_away',
                    'value' => $home[1],
                    'compare' => '='
                ), array(
                    'key' => 'is_finish',
                    'value' => true,
                    'compare' => '='
                )
            ),
        ),
        'orderby' => 'meta_value_num',
        'meta_key' => 'tanggal_main',
        'order' => 'desc',
    );

    Can you suggest me for better query.

  • The problem is not with ACF, the problem is that multiple joins to the postmeta table slow WP down, and the fix that WP put in for this does not really fix the problem. Here is the current ticket for this I believe https://core.trac.wordpress.org/ticket/30044

    If you do a search for “multiple meta queries slow down wp” you might find some possible solutions.

Viewing 2 posts - 1 through 2 (of 2 total)

The topic ‘Query ACF too slow’ is closed to new replies.