From 0f3921f7713b1866e7992e39c46bb640282d748d Mon Sep 17 00:00:00 2001 From: Ryan Boren Date: Mon, 18 Apr 2011 20:38:59 +0000 Subject: [PATCH] More efficient term intersection query. Props tigertech. see #16706 git-svn-id: https://develop.svn.wordpress.org/trunk@17652 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-includes/taxonomy.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/wp-includes/taxonomy.php b/wp-includes/taxonomy.php index 33d4329deb..eab8d19703 100644 --- a/wp-includes/taxonomy.php +++ b/wp-includes/taxonomy.php @@ -694,12 +694,12 @@ class WP_Tax_Query { $terms = implode( ',', $terms ); - $where[] = "$primary_table.$primary_id_column IN ( - SELECT object_id + $where[] = "( + SELECT COUNT(1) FROM $wpdb->term_relationships WHERE term_taxonomy_id IN ($terms) - GROUP BY object_id HAVING COUNT(object_id) = $num_terms - )"; + AND object_id = $primary_table.$primary_id_column + ) = $num_terms"; } $i++;