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

select
r=LpSolit, a=glob


git-svn-id: svn://10.0.0.236/trunk@265386 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
bzrmirror%bugzilla.org 2014-05-05 07:30:44 +00:00
parent 3f7ab81853
commit 4dbd6fb4a5
3 changed files with 9 additions and 2 deletions

View File

@ -1 +1 @@
9020
9021

View File

@ -1 +1 @@
0e18b44ee2dc59bf5b0816fd2a26a90b81057384
b0df54c7f19387f72124b53431473374db26c0cf

View 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";