diff -urp views_old/modules/views_taxonomy.inc views/modules/views_taxonomy.inc
--- views_old/modules/views_taxonomy.inc	2007-07-14 21:30:51.000000000 +0200
+++ views/modules/views_taxonomy.inc	2008-08-27 15:04:26.000000000 +0200
@@ -496,20 +496,32 @@ function _views_add_taxonomy($op, $value
   // a 2 dimensional array.
 
   if ($op == 'OR') {
-    $num = $query->add_table('term_node');
-    $tablename = $query->get_table_name('term_node', $num);
-    $clause = "'" . implode("','", $value) . "'";
-    $where = "$tablename.tid IN ($clause)";
+     // Build a subquery for depth instead of making a ton of left joins
+    $clause = "'" . implode("','", $value) ."'";
+    $sub_query = "SELECT term_hierarchy1.tid FROM {term_hierarchy} term_hierarchy1";
+    $sub_join = "";
+    $sub_where = "WHERE term_hierarchy1.tid IN ($clause)";
+
+    for ($i=1; $i<=$depth; ++$i) {
+      $thnum = $i+1;
+      $sub_join .= " LEFT JOIN {term_hierarchy} term_hierarchy$thnum ON term_hierarchy$i.parent = term_hierarchy$thnum.tid";
+      $sub_where .= " OR term_hierarchy$thnum.tid IN ($clause)";
+    }
+    $sub_query ="$sub_query $sub_join $sub_where";
 
-    // for each depth > 0, add the next parent in term_hierarchy to the join
-    $thnum = $query->add_table('term_hierarchy', false, 1, array('left' => array('table' => $tablename, 'field' => 'tid'), 'right' => array('field' => 'tid')));
-    $tablename = $query->get_table_name('term_hierarchy', $thnum);
-    for ($i = 0; $i < $depth; $i++) {
-      $thnum = $query->add_table('term_hierarchy', false, 1, array('left' => array('table' => $tablename, 'field' => 'parent'), 'right' => array('field' => 'tid')));
-      $tablename = $query->get_table_name('term_hierarchy', $thnum);
-      $where .= " OR $tablename.tid IN ($clause)";
+    // Submit the subquery directly and build resulting list
+    $cursor = db_query($sub_query);
+    $sub_list = "";
+    while ($th_tid=db_fetch_array($cursor)) {
+      $sub_list .= "${th_tid['tid']},";
     }
-    $query->add_where($where);
+    $sub_list=rtrim($sub_list, ",");
+
+    // Use the subquery results in the main query
+    $num = $query->add_table('term_node');
+    $tablename = $query->get_table_name('term_node', $num);
+    $where = "$tablename.tid IN ($sub_list)";
+    $query->add_where($where);    
   }
   else if ($op == 'NOR') {
     //ignore the depth for this case
@@ -522,20 +534,31 @@ function _views_add_taxonomy($op, $value
   }
   else {
     foreach ($value as $tid) {
-      // For every term we have to match add the depth chain
-      $num = $query->add_table('term_node');
-      $tablename = $query->get_table_name('term_node', $num);
-      $where = "$tablename.tid = '$tid'";
+      // Build a subquery for depth instead of making a ton of left joins
+      $sub_query = "SELECT term_hierarchy1.tid FROM {term_hierarchy} term_hierarchy1";
+      $sub_join = "";
+      $sub_where = "WHERE term_hierarchy1.tid = $tid";
+
+      for ($i=1; $i<=$depth; ++$i) {
+        $thnum = $i+1;
+        $sub_join .= " LEFT JOIN {term_hierarchy} term_hierarchy$thnum ON term_hierarchy$i.parent = term_hierarchy$thnum.tid";
+        $sub_where .= " OR term_hierarchy$thnum.tid = $tid";
+      }
+      $sub_query ="$sub_query $sub_join $sub_where";
 
-      // for each depth > 0, add the next parent in term_hierarchy to the join
-      $thnum = $query->add_table('term_hierarchy', false, 1, array('left' => array('table' => $tablename, 'field' => 'tid'), 'right' => array('field' => 'tid')));
-      $tablename = $query->get_table_name('term_hierarchy', $thnum);
-      for ($i = 0; $i < $depth; $i++) {
-        $thnum = $query->add_table('term_hierarchy', false, 1, array('left' => array('table' => $tablename, 'field' => 'parent'), 'right' => array('field' => 'tid')));
-        $tablename = $query->get_table_name('term_hierarchy', $thnum);
-        $where .= " OR $tablename.tid = '$tid'";
+      // Submit the subquery directly and build resulting list
+      $cursor = db_query($sub_query);
+      $sub_list = "";
+      while ($th_tid=db_fetch_array($cursor)) {
+        $sub_list .= "${th_tid['tid']},";
       }
-      $query->add_where($where);
+      $sub_list=rtrim($sub_list, ",");
+
+      // Use the subquery results in the main query
+      $num = $query->add_table('term_node');
+      $tablename = $query->get_table_name('term_node', $num);
+      $where = "$tablename.tid IN ($sub_list)";
+      $query->add_where($where);    
     }
   }
 }
