Commit cbc08e72 authored by Byron Jones's avatar Byron Jones

Bug 999331: searching attachment data is very slow due to an unbounded

select r=LpSolit, a=glob
parent 2a737207
......@@ -1968,6 +1968,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";
......
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