Bug 179960 - Qucksearch queries are slow and timeout

fixed by adding subselect emulation for product/component lookups r=joel, a=justdave
parent 3e4c5032
...@@ -514,17 +514,22 @@ sub init { ...@@ -514,17 +514,22 @@ sub init {
}, },
"^component,(?!changed)" => sub { "^component,(?!changed)" => sub {
my $table = "components_$chartid"; $f = $ff = "components.name";
push(@supptables, "components $table"); $funcsbykey{",$t"}->();
push(@wherepart, "bugs.component_id = $table.id"); $term = build_subselect("bugs.component_id",
$f = $ff = "$table.name"; "components.id",
"components",
$term);
}, },
"^product,(?!changed)" => sub { "^product,(?!changed)" => sub {
my $table = "products_$chartid"; # Generate the restriction condition
push(@supptables, "products $table"); $f = $ff = "products.name";
push(@wherepart, "bugs.product_id = $table.id"); $funcsbykey{",$t"}->();
$f = $ff = "$table.name"; $term = build_subselect("bugs.product_id",
"products.id",
"products",
$term);
}, },
"^keywords," => sub { "^keywords," => sub {
...@@ -591,9 +596,12 @@ sub init { ...@@ -591,9 +596,12 @@ sub init {
",casesubstring" => sub { ",casesubstring" => sub {
$term = "INSTR($ff, $q)"; $term = "INSTR($ff, $q)";
}, },
",(substring|substr)" => sub { ",substring" => sub {
$term = "INSTR(LOWER($ff), " . lc($q) . ")"; $term = "INSTR(LOWER($ff), " . lc($q) . ")";
}, },
",substr" => sub {
$funcsbykey{",substring"}->();
},
",notsubstring" => sub { ",notsubstring" => sub {
$term = "INSTR(LOWER($ff), " . lc($q) . ") = 0"; $term = "INSTR(LOWER($ff), " . lc($q) . ") = 0";
}, },
...@@ -1016,6 +1024,19 @@ sub ListIDsForEmail { ...@@ -1016,6 +1024,19 @@ sub ListIDsForEmail {
return $list; return $list;
} }
sub build_subselect {
my ($outer, $inner, $table, $cond) = @_;
my $q = "SELECT $inner FROM $table WHERE $cond";
#return "$outer IN ($q)";
&::SendSQL($q);
my @list;
while (&::MoreSQLData()) {
push (@list, &::FetchOneColumn());
}
return "1=2" unless @list; # Could use boolean type on dbs which support it
return "$outer IN (" . join(',', @list) . ")";
}
sub GetByWordList { sub GetByWordList {
my ($field, $strs) = (@_); my ($field, $strs) = (@_);
my @list; my @list;
......
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