Skip to content

Commit

Permalink
Improve the last_build queries - they had got noticeably slow
Browse files Browse the repository at this point in the history
  • Loading branch information
adunstan committed Oct 10, 2012
1 parent 6c65f7d commit a81cea3
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions cgi-bin/show_log.pl
Original file line number Diff line number Diff line change
Expand Up @@ -58,16 +58,20 @@
};
my $last_build_statement = q{
select distinct on (sysname) sysname, snapshot, stage, git_head_ref
from build_status
where sysname = ? and branch = ? and snapshot < ?
order by sysname, snapshot desc limit 1
select git_head_ref
from build_status
where sysname = ? and branch = ? and snapshot =
(select max(snapshot)
from build_status
where sysname = ? and branch = ? and snapshot < ?)
};
my $last_success_statement = q{
select distinct on (sysname) sysname, snapshot, git_head_ref
from build_status
where sysname = ? and branch = ? and snapshot < ? and stage = 'OK'
order by sysname, snapshot desc limit 1
select git_head_ref
from build_status
where sysname = ? and branch = ? and snapshot =
(select max(snapshot)
from build_status
where sysname = ? and branch = ? and snapshot < ? and stage = 'OK')
};
my $sth=$db->prepare($statement);
$sth->execute($system,$logdate);
Expand All @@ -80,7 +84,7 @@
{
$last_build_row =
$db->selectrow_hashref($last_build_statement,undef,
$system,$branch,$logdate);
$system, $branch,$system,$branch,$logdate);
$last_build_git_ref = $last_build_row->{git_head_ref}
if $last_build_row;

Expand All @@ -90,7 +94,7 @@
{
$last_success_row =
$db->selectrow_hashref($last_success_statement,undef,
$system,$branch,$logdate);
$system,$branch,$system,$branch,$logdate);
$last_success_git_ref = $last_success_row->{git_head_ref}
if $last_success_row;
}
Expand Down

0 comments on commit a81cea3

Please sign in to comment.