Comment 3 for bug 315458

Revision history for this message
Stuart Bishop (stub) wrote :

The following form is much faster when we are dealing with a huge number of matching sourcepackagereleases:

SELECT COUNT(DISTINCT Build.id)
FROM
    Archive, Build, BuildQueue, Distribution, DistroArchSeries, DistroSeries,
    SourcePackageRelease, SourcePackageName
WHERE
    distroarchseries IN (
        81, 87, 80, 82, 83, 84, 85, 86, 77, 75, 78, 73, 76, 79, 74, 66, 70, 67, 71, 68, 72, 69,
        59, 60, 61, 62, 65, 63, 64, 47, 49, 51, 52, 48, 50, 38, 35, 39, 36, 40, 37, 16, 21, 17,
        28, 18, 19, 14, 26, 13, 25, 15, 24, 8, 7, 23, 9, 22, 11, 10, 12)
    AND NOT (Build.buildstate = 1 AND Build.datebuilt is NULL)
    AND BuildQueue.build = Build.id
    AND buildstate=0
    AND Build.sourcepackagerelease = SourcePackageRelease.id
    AND SourcePackageRelease.sourcepackagename = SourcePackageName.id
    AND SourcepackageName.name LIKE '%' || 'gnome-' || '%'
    AND Build.distroarchseries = DistroArchSeries.id
    AND DistroArchSeries.distroseries = DistroSeries.id
    AND DistroSeries.distribution = Distribution.id
    AND Distribution.id = Archive.distribution
    AND Archive.purpose IN (1,4)
    AND Archive.id = Build.archive;

We should test this variant on edge or staging to see if it also performs well for more normal requests.