]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 999331: searching attachment data is very slow due to an unbounded
authorByron Jones <glob@mozilla.com>
Mon, 5 May 2014 07:15:18 +0000 (15:15 +0800)
committerByron Jones <glob@mozilla.com>
Mon, 5 May 2014 07:15:18 +0000 (15:15 +0800)
select
r=LpSolit, a=glob

Bugzilla/Search.pm

index 1c008bdfb5c78658e5d057f52ef19c1aec8b5063..75a0fbdb45c5d855bd0d6546ffd2e9c0007a89f9 100644 (file)
@@ -2053,6 +2053,13 @@ sub _quote_unless_numeric {
 
 sub build_subselect {
     my ($outer, $inner, $table, $cond, $negate) = @_;
+    if ($table =~ /\battach_data\b/) {
+        # It takes a long time to scan the whole attach_data table
+        # unconditionally, so we return the subselect and let the DB optimizer
+        # restrict the search based on other search criteria.
+        my $not = $negate ? "NOT" : "";
+        return "$outer $not IN (SELECT DISTINCT $inner FROM $table WHERE $cond)";
+    }
     # Execute subselects immediately to avoid dependent subqueries, which are
     # large performance hits on MySql
     my $q = "SELECT DISTINCT $inner FROM $table WHERE $cond";