Index: src/wp-includes/link-template.php
===================================================================
--- src/wp-includes/link-template.php	(revision 29671)
+++ src/wp-includes/link-template.php	(working copy)
@@ -1500,18 +1500,22 @@
 				return '';
 			$term_array = wp_get_object_terms( $post->ID, $taxonomy, array( 'fields' => 'ids' ) );
 
+			if ( ! $term_array || is_wp_error( $term_array ) )
+				return '';
+
 			// Remove any exclusions from the term array to include.
 			$term_array = array_diff( $term_array, (array) $excluded_terms );
 			$term_array = array_map( 'intval', $term_array );
 
-			if ( ! $term_array || is_wp_error( $term_array ) )
+			if ( ! $term_array )
 				return '';
 
 			$where .= " AND tt.term_id IN (" . implode( ',', $term_array ) . ")";
 		}
 
 		if ( ! empty( $excluded_terms ) ) {
-			$where .= " AND p.ID NOT IN ( SELECT object_id FROM $wpdb->term_relationships WHERE term_taxonomy_id IN (" . implode( $excluded_terms, ',' ) . ') )';
+			$join .= " LEFT JOIN $wpdb->term_relationships AS tr2 ON p.ID = tr2.object_id AND tr2.term_taxonomy_id IN (" . implode( ',', $excluded_terms ) . ")";
+			$where .= " AND tr2.object_id IS NULL";
 		}
 	}
 
