When searching a path / drv path, use separate queries for both options to prevent seq. scan.

This commit is contained in:
Rob Vermaas 2013-04-26 08:51:49 -04:00
parent 591aee0793
commit fd7acd9bbf
2 changed files with 25 additions and 9 deletions

View file

@ -296,10 +296,15 @@ sub search :Local Args(0) {
, rows => $c->stash->{limit} + 1
} ) ];
# Perform build search in separate queries to prevent seq scan on buildoutputs table.
$c->stash->{builds} = [ $c->model('DB::Builds')->search(
{ -or => { "buildoutputs.path" => trim($query), "drvpath" => trim($query)} },
{ "buildoutputs.path" => trim($query) },
{ order_by => ["id desc"], join => ["buildoutputs"] } ) ];
$c->stash->{buildsdrv} = [ $c->model('DB::Builds')->search(
{ "drvpath" => trim($query) },
{ order_by => ["id desc"] } ) ];
}

View file

@ -1,6 +1,21 @@
[% WRAPPER layout.tt title="Search results" %]
[% PROCESS common.tt %]
[% matched = 0 %]
[% BLOCK renderBuildSearch %]
[% IF builds.size > 0 %]
<p>The following builds match your query:[% IF builds.size > limit %] <span class="text-warning">(first [% limit %] results only)</span>[% END %]</p>
[% INCLUDE renderBuildList %]
[% END %]
[% END; %]
[% IF projects.size > 0; matched = 1 %]
<p>The following projects match your query:</p>
@ -60,17 +75,13 @@
[% END %]
[% IF builds.size > 0; matched = 1 %]
[% INCLUDE renderBuildSearch %]
[% INCLUDE renderBuildSearch builds=buildsdrv %]
<p>The following builds match your query:[% IF jobs.size > limit %] <span class="text-warning">(first [% limit %] results only)</span>[% END %]</p>
[% INCLUDE renderBuildList %]
[% END %]
[% IF builds.size > 0 || buildsdrv.size > 0 ; matched = 1 ; END %]
[% IF !matched %]
<div class="alert alert-warn">Sorry! Nothing matches your
query.</div>
<div class="alert alert-warn">Sorry! Nothing matches your query.</div>
[% END %]
[% END %]