diff options
author | Frédéric Buclin <LpSolit@gmail.com> | 2013-01-03 14:45:13 +0100 |
---|---|---|
committer | Frédéric Buclin <LpSolit@gmail.com> | 2013-01-03 14:45:13 +0100 |
commit | 48e96823d3ebc484589222e3c5a83fea90997856 (patch) | |
tree | 780b7cd445ee93aad34ac854a3fa88313ecdb0d5 /Bugzilla | |
parent | 28d94456ca0912e7af8a6f129fe6b03d8b6310f0 (diff) | |
download | bugzilla-48e96823d3ebc484589222e3c5a83fea90997856.tar.gz bugzilla-48e96823d3ebc484589222e3c5a83fea90997856.tar.xz |
Bug 824262: Querying for strings in comments is now ultra slow
r=glob a=LpSolit
Diffstat (limited to 'Bugzilla')
-rw-r--r-- | Bugzilla/Search.pm | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/Bugzilla/Search.pm b/Bugzilla/Search.pm index 71893a5fc..b05da1a04 100644 --- a/Bugzilla/Search.pm +++ b/Bugzilla/Search.pm @@ -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 |