Bug 824262: Querying for strings in comments is now ultra slow

r=glob a=LpSolit


git-svn-id: svn://10.0.0.236/trunk@264620 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
mkanat%bugzilla.org 2013-01-03 14:00:55 +00:00
parent 90c5ded374
commit a063a77cc1
2 changed files with 19 additions and 8 deletions

View File

@ -1 +1 @@
8546
8547

View File

@ -1915,13 +1915,24 @@ sub _quote_unless_numeric {
sub build_subselect {
my ($outer, $inner, $table, $cond, $negate) = @_;
# Execute subselects immediately to avoid dependent subqueries, which are
# large performance hits on MySql
my $q = "SELECT DISTINCT $inner FROM $table WHERE $cond";
my $dbh = Bugzilla->dbh;
my $list = $dbh->selectcol_arrayref($q);
return $negate ? "1=1" : "1=2" unless @$list;
return $dbh->sql_in($outer, $list, $negate);
if ($table eq 'longdescs') {
# There is no index on the longdescs.thetext column and so it takes
# a long time to scan the whole table unconditionally. For this table,
# we return the subselect and let the DB optimizer restrict the search
# to some given bug list only based on other search criteria available.
my $not = $negate ? "NOT" : "";
return "$outer $not IN (SELECT DISTINCT $inner FROM $table WHERE $cond)";
}
else {
# Execute subselects immediately to avoid dependent subqueries, which are
# large performance hits on MySql
my $q = "SELECT DISTINCT $inner FROM $table WHERE $cond";
my $dbh = Bugzilla->dbh;
my $list = $dbh->selectcol_arrayref($q);
return $negate ? "1=1" : "1=2" unless @$list;
return $dbh->sql_in($outer, $list, $negate);
}
}
# Used by anyexact to get the list of input values. This allows us to