This denormalises the database, but it's the best we can do until PostgreSQL has materialised views.
2JGYLIEC6A4HU6Y4FVMBMAKV4YF2ZNJPVNZGCS4AWDTQW5BWBHXQC alter table JobsetEvalsadd column nrBuilds integer,add column nrSucceeded integer;update JobsetEvals e setnrBuilds = (select count(*) from JobsetEvalMembers m where e.id = m.eval)where hasNewBuilds = 1;