639 | | foreach ( $this->queries as $query ) { |
| 639 | // convert AND queries to IN ones for more efficient SQL |
| 640 | if ( 'AND' == $this->relation ) { |
| 641 | $final_queries = array(); |
| 642 | foreach ( $this->queries as $query ) { |
| 643 | if ( 'AND' == $query['operator'] && count( $query['terms'] ) <= 10 ) { |
| 644 | foreach ( $query['terms'] as $term ) { |
| 645 | $final_queries[] = array_merge( $query, array( |
| 646 | 'terms' => $term, |
| 647 | 'operator' => 'IN' |
| 648 | ) ); |
| 649 | } |
| 650 | } else { |
| 651 | $final_queries[] = $query; |
| 652 | } |
| 653 | } |
| 654 | } else { |
| 655 | $final_queries = $this->queries; |
| 656 | } |
| 657 | |
| 658 | foreach ( $final_queries as $query ) { |