Commit 73aac8b5 authored by Frédéric Buclin's avatar Frédéric Buclin

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

r=glob a=LpSolit
parent 5050c53e
...@@ -1912,13 +1912,24 @@ sub _quote_unless_numeric { ...@@ -1912,13 +1912,24 @@ sub _quote_unless_numeric {
sub build_subselect { sub build_subselect {
my ($outer, $inner, $table, $cond, $negate) = @_; my ($outer, $inner, $table, $cond, $negate) = @_;
# Execute subselects immediately to avoid dependent subqueries, which are
# large performance hits on MySql if ($table eq 'longdescs') {
my $q = "SELECT DISTINCT $inner FROM $table WHERE $cond"; # There is no index on the longdescs.thetext column and so it takes
my $dbh = Bugzilla->dbh; # a long time to scan the whole table unconditionally. For this table,
my $list = $dbh->selectcol_arrayref($q); # we return the subselect and let the DB optimizer restrict the search
return $negate ? "1=1" : "1=2" unless @$list; # to some given bug list only based on other search criteria available.
return $dbh->sql_in($outer, $list, $negate); 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 # Used by anyexact to get the list of input values. This allows us to
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment