diff options
author | bbaetz%student.usyd.edu.au <> | 2002-11-18 11:03:31 +0100 |
---|---|---|
committer | bbaetz%student.usyd.edu.au <> | 2002-11-18 11:03:31 +0100 |
commit | f1b4d836b3e40e86799ab8aaa6f61e6c6d9d9d82 (patch) | |
tree | 57df307d02d8b54f0f4a64ed99f3638d9dbf975c /Bugzilla | |
parent | 3e4c503273cd8c1ab6e9dce41ce507ca2caa1885 (diff) | |
download | bugzilla-f1b4d836b3e40e86799ab8aaa6f61e6c6d9d9d82.tar.gz bugzilla-f1b4d836b3e40e86799ab8aaa6f61e6c6d9d9d82.tar.xz |
Bug 179960 - Qucksearch queries are slow and timeout
fixed by adding subselect emulation for product/component lookups
r=joel, a=justdave
Diffstat (limited to 'Bugzilla')
-rw-r--r-- | Bugzilla/Search.pm | 39 |
1 files changed, 30 insertions, 9 deletions
diff --git a/Bugzilla/Search.pm b/Bugzilla/Search.pm index c80bb99e7..3ac654ccc 100644 --- a/Bugzilla/Search.pm +++ b/Bugzilla/Search.pm @@ -514,17 +514,22 @@ sub init { }, "^component,(?!changed)" => sub { - my $table = "components_$chartid"; - push(@supptables, "components $table"); - push(@wherepart, "bugs.component_id = $table.id"); - $f = $ff = "$table.name"; + $f = $ff = "components.name"; + $funcsbykey{",$t"}->(); + $term = build_subselect("bugs.component_id", + "components.id", + "components", + $term); }, "^product,(?!changed)" => sub { - my $table = "products_$chartid"; - push(@supptables, "products $table"); - push(@wherepart, "bugs.product_id = $table.id"); - $f = $ff = "$table.name"; + # Generate the restriction condition + $f = $ff = "products.name"; + $funcsbykey{",$t"}->(); + $term = build_subselect("bugs.product_id", + "products.id", + "products", + $term); }, "^keywords," => sub { @@ -591,9 +596,12 @@ sub init { ",casesubstring" => sub { $term = "INSTR($ff, $q)"; }, - ",(substring|substr)" => sub { + ",substring" => sub { $term = "INSTR(LOWER($ff), " . lc($q) . ")"; }, + ",substr" => sub { + $funcsbykey{",substring"}->(); + }, ",notsubstring" => sub { $term = "INSTR(LOWER($ff), " . lc($q) . ") = 0"; }, @@ -1016,6 +1024,19 @@ sub ListIDsForEmail { 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 { my ($field, $strs) = (@_); my @list; |