Commit 0b0df3f2 authored by Leigh B Stoller's avatar Leigh B Stoller

Performance improvements to the query; it was taking too long.

parent 3a5a1ba9
<?php <?php
# #
# Copyright (c) 2000-2012 University of Utah and the Flux Group. # Copyright (c) 2000-2013 University of Utah and the Flux Group.
# #
# {{{EMULAB-LICENSE # {{{EMULAB-LICENSE
# #
...@@ -117,12 +117,13 @@ elseif ($showby == "project") { ...@@ -117,12 +117,13 @@ elseif ($showby == "project") {
USERERROR("Must supply a project to view!", 1); USERERROR("Must supply a project to view!", 1);
} }
$pid = $target_project->pid(); $pid = $target_project->pid();
$pid_idx = $target_project->pid_idx();
if (!$target_project->AccessCheck($this_user, $TB_PROJECT_READINFO)) { if (!$target_project->AccessCheck($this_user, $TB_PROJECT_READINFO)) {
USERERROR("You do not have permission to view stats for ". USERERROR("You do not have permission to view stats for ".
"project $pid!", 1); "project $pid!", 1);
} }
$wclause = "where (s.pid='$pid')"; $wclause = "where (s.pid_idx='$pid_idx')";
} }
elseif ($showby == "expt") { elseif ($showby == "expt") {
# #
...@@ -167,12 +168,13 @@ elseif ($showby == "expt") { ...@@ -167,12 +168,13 @@ elseif ($showby == "expt") {
elseif ($showby == "all") { elseif ($showby == "all") {
if (isset($target_project)) { if (isset($target_project)) {
$pid = $target_project->pid(); $pid = $target_project->pid();
$pid_idx = $target_project->pid_idx();
if (!$target_project->AccessCheck($this_user, $TB_PROJECT_READINFO)) { if (!$target_project->AccessCheck($this_user, $TB_PROJECT_READINFO)) {
USERERROR("You do not have permission to view stats for ". USERERROR("You do not have permission to view stats for ".
"project $pid!", 1); "project $pid!", 1);
} }
$wclause = "where (s.pid='$pid')"; $wclause = "where (s.pid_idx='$pid_idx')";
} }
elseif (!$isadmin) { elseif (!$isadmin) {
# #
...@@ -213,7 +215,7 @@ $query_result = ...@@ -213,7 +215,7 @@ $query_result =
DBQueryFatal("select t.exptidx,s.pid,s.eid,t.action,t.exitcode,t.uid, ". DBQueryFatal("select t.exptidx,s.pid,s.eid,t.action,t.exitcode,t.uid, ".
" r.pnodes,t.idx as statno,t.start_time,t.end_time, ". " r.pnodes,t.idx as statno,t.start_time,t.end_time, ".
" s.archive_idx,r.archive_tag,t.uid_idx ". " s.archive_idx,r.archive_tag,t.uid_idx ".
" from testbed_stats as t force index (end_time, idx) ". " from testbed_stats as t ".
"left join experiment_stats as s on s.exptidx=t.exptidx ". "left join experiment_stats as s on s.exptidx=t.exptidx ".
"left join experiment_resources as r on r.idx=t.rsrcidx ". "left join experiment_resources as r on r.idx=t.rsrcidx ".
"$wclause ". "$wclause ".
......
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