+download issues too many queries to retrieve time of last download

Bug #388082 reported by Guilherme Salgado
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Launchpad itself
Fix Released
High
Guilherme Salgado

Bug Description

https://edge.launchpad.net/bzr/+download is currently issuing more than 600 queries just to fetch the time of the last download for files listed there: OOPS-1263EA751

There's an easy fix that will cut that number down by 2/3, but we'd still be issuing around 200 queries, which is almost the total number of queries issued by that page before the download counts appeared there.

Tags: lp-registry
summary: - +download issues too many queries to retrieve download counts
+ +download issues too many queries to retrieve time of last download
description: updated
Changed in launchpad-registry:
status: Triaged → In Progress
Revision history for this message
Stuart Bishop (stub) wrote :

The following query retrieves all the information I think is needed to render the entire report. It runs in about a second for bzr, and gives the running hit count rather than the cached count (there is no performance improvement using LibraryFileAlias.hits over SUM(count) ). It should be possible to convert this to Storm syntax if you want. The result will need to be transformed into a data structure usable by the existing template, or the existing template rewritten.

SELECT
    Product.name,
    ProductSeries.name,
    SignatureAlias.id AS signature_id,
    Milestone.name,
    ProductReleaseFile.description,
    LibraryFileAlias.id,
    LibraryFileAlias.filename,
    LibraryFileContent.filesize,
    SUM(count),
    MAX(day) AS last_downloaded
FROM
    Product
    JOIN ProductSeries ON ProductSeries.product = Product.id
    JOIN Milestone ON Milestone.productseries = ProductSeries.id
    JOIN ProductRelease ON ProductRelease.milestone = Milestone.id
    JOIN ProductReleaseFile
        ON ProductReleaseFile.productrelease = ProductRelease.id
    JOIN LibraryFileAlias
        ON LibraryFileAlias.id = ProductReleaseFile.libraryfile
    JOIN LibraryFileContent
        ON LibraryFileContent.id = LibraryFileAlias.content
    LEFT OUTER JOIN LibraryFileDownloadCount
        ON LibraryFileDownloadCount.libraryfilealias = LibraryFileAlias.id
    LEFT OUTER JOIN LibraryFileAlias AS SignatureAlias
        ON SignatureAlias.id = ProductReleaseFile.signature
WHERE
    Product.name = 'bzr'

GROUP BY
    Product.name,
    ProductSeries.name,
    signature_id,
    Milestone.name,
    ProductReleaseFile.description,
    LibraryFileAlias.id,
    LibraryFileAlias.filename,
    LibraryFileContent.filesize

ORDER BY
    ProductSeries.name,
    Milestone.name,
    LibraryFileAlias.filename;

Revision history for this message
Guilherme Salgado (salgado) wrote :

bug 389596 is about the proper fix

Changed in launchpad-registry:
status: In Progress → Fix Committed
Revision history for this message
Curtis Hovey (sinzui) wrote : Bug 388082 Fix released

Fixed released in Launchpad 2.2.6.

Changed in launchpad-registry:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.