Use faster query to determine number of running builds

The previous query

select count(*) from builds b left join buildsteps s on s.build = b.id where busy = 1 and finished = 0

is suddenly taking several minutes. Probably PostgreSQL decided to use a suboptimal query plan.

Created by  Eelco Dolstra  on March 16, 2016
E46TNJK6LJK5GSNQM63D647NXTAKXZNG6N6O6B3ETOMDKPGCD6KQC
Change contents