Eliminate one db call in IP subnet utilization report. Limit clause is not applied until after all rows to be returned are calculated so calling has_rows provides no optimization versus calling ->all in controller and checking for results before sending to template. Also use HashRefInflator.

This commit is contained in:
Eric A. Miller
2014-06-07 14:52:26 -04:00
parent 2e6deba1a6
commit c8b05263e6
3 changed files with 8 additions and 11 deletions

View File

@@ -24,18 +24,20 @@ get '/ajax/content/report/subnets' => require_login sub {
$start = $tmp;
}
my $set = schema('netdisco')->resultset('Virtual::SubnetUtilization')
my @results = schema('netdisco')->resultset('Virtual::SubnetUtilization')
->search(undef,{
bind => [ $subnet, $start, $end, $end, $subnet, $end, $end ],
});
})->hri->all;
return unless scalar @results;
if ( request->is_ajax ) {
template 'ajax/report/subnets.tt', { results => $set },
template 'ajax/report/subnets.tt', { results => \@results },
{ layout => undef };
}
else {
header( 'Content-Type' => 'text/comma-separated-values' );
template 'ajax/report/subnets_csv.tt', { results => $set },
template 'ajax/report/subnets_csv.tt', { results => \@results },
{ layout => undef };
}
};