From 746bb77bf3d97af29dfe4fc2b1bde2c74624a809 Mon Sep 17 00:00:00 2001 From: ryan Date: Mon, 18 Apr 2011 20:38:59 +0000 Subject: [PATCH] More efficient term intersection query. Props tigertech. see #16706 git-svn-id: http://svn.automattic.com/wordpress/trunk@17652 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- 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 33d4329de..eab8d1970 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++;