$group_by_ok=false;// Don't actually need to do a group by, as no duplication possible. We want to avoid GROUP BY as it forces MySQL to create a temporary table, slowing things down a lot.
}
// This is so for example catalogue_entries.php can use brackets in it's table specifier while avoiding the table prefix after the first bracket. A bit weird, but that's our convention and it does save a small amount of typing
$group_by_ok=false;// Don't actually need to do a group by, as no duplication possible. We want to avoid GROUP BY as it forces MySQL to create a temporary table, slowing things down a lot.
}
// Work out main query
$query='';
$main_query_parts=array();
@@ -1288,6 +1292,10 @@ function get_search_rows($meta_type, $meta_id_field, $content, $boolean_search,
$_count_query_main_search='SELECT ('.$_query.')';
}
// Won't work for UNION clauses unfortunately. De-dupe further on will fix, but not the count.
//$_count_query_main_search .= ($group_by_ok ? ' GROUP BY r.id' : '');
//$query .= ($group_by_ok ? ' GROUP BY r.id' : '');
$group_by_ok=false;// Don't actually need to do a group by, as no duplication possible. We want to avoid GROUP BY as it forces MySQL to create a temporary table, slowing things down a lot.
}
// Work out our queries
$query=' FROM '.$table_clause.(($where_clause=='')?'':(' WHERE '.$where_clause));
if($where_clause_and!=''){
$query.=(($where_clause=='')?' WHERE ':' AND ').'('.$where_clause_and.')';
}
if($group_by_ok&&false/*Actually we cannot assume that r.id exists*/){
}else{// Has to do a nested subquery to reduce scope of COUNT(*), because the unbounded full-text's binary tree descendance can be extremely slow on physical disks if common words exist that aren't defined as MySQL stop words
@@ -1452,8 +1453,7 @@ function get_search_rows($meta_type, $meta_id_field, $content, $boolean_search,
$_count_query_main_search='(SELECT COUNT(*) FROM ('.$tmp_subquery.') counter)';
}
}
$query='SELECT '.$select.$query.($group_by_ok?' GROUP BY r.id':'');