Make WordPress Core


Ignore:
Timestamp:
10/16/2017 06:34:29 PM (7 years ago)
Author:
boonebgorges
Message:

Don't force distinct term queries when specifying number and object_ids.

This reverts [41377], which caused performance problems on sites with a large
number of terms.

See #41796.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/class-wp-term-query.php

    r41769 r41880  
    554554        }
    555555
    556         $do_distinct = false;
    557 
    558         /*
    559          * Duplicate terms are generally removed when necessary after the database query.
    560          * But when a LIMIT clause is included in the query, we let MySQL enforce
    561          * distinctness so the count is correct.
    562          */
    563         if ( ! empty( $limits ) && 'all_with_object_id' !== $args['fields'] ) {
    564             $do_distinct = true;
    565         }
    566556
    567557        if ( ! empty( $args['search'] ) ) {
     
    581571            $join .= $mq_sql['join'];
    582572            $this->sql_clauses['where']['meta_query'] = preg_replace( '/^\s*AND\s*/', '', $mq_sql['where'] );
    583             $do_distinct = true;
     573            $distinct .= "DISTINCT";
     574
    584575        }
    585576
     
    643634        $where = implode( ' AND ', $this->sql_clauses['where'] );
    644635
    645         $distinct = $do_distinct ? 'DISTINCT' : '';
    646 
    647636        /**
    648637         * Filters the terms query SQL clauses.
Note: See TracChangeset for help on using the changeset viewer.