Comment 5 for bug 328302

Revision history for this message
Tim Penhey (thumper) wrote :

jml and I spent some time talking about this, and much of what we do in code can be done with the following single sql call. It is however a little slow (https://pastebin.canonical.com/14346/). Can this be made faster? Or should we look into denormalisation?

select count(distinct(Revision.id)) as revision_count,
 count(distinct(
    coalesce(RevisionAuthor.person, -RevisionAuthor.id))) as committer_count
from Revision
join RevisionAuthor on Revision.revision_author = RevisionAuthor.id
join BranchRevision on BranchRevision.revision = Revision.id
join Branch on BranchRevision.branch = Branch.id
where
    Revision.revision_date > '2009-02-01'
AND Revision.revision_date <= '2009-02-27'
and Branch.product = 10294
and BranchRevision.revision >= (
  select min(id) from revision where revision_date > '2009-02-01')