Review count script should be more efficient

RESOLVED WORKSFORME

Status

addons.mozilla.org Graveyard
Maintenance Scripts
P5
enhancement
RESOLVED WORKSFORME
8 years ago
2 years ago

People

(Reporter: davedash, Unassigned)

Tracking

unspecified
4.x (triaged)
x86
Mac OS X

Details

(Whiteboard: [workqueue])

PHP Notice:  MySQL Error 0: 
Query was: [
           UPDATE addons AS a
           INNER JOIN (
               SELECT
                   versions.addon_id as addon_id,
                   COUNT(*) as count
               FROM reviews
               INNER JOIN versions ON reviews.version_id = versions.id
               WHERE reviews.reply_to IS NULL
                   AND reviews.rating > 0
               GROUP BY versions.addon_id
           ) AS c ON (a.id = c.addon_id)
           SET a.totalreviews = c.count
       ] in /data/amo/www/addons.mozilla.org-remora/bin/database.class.php on line 130


This query is expensive.  It has to go through each addon, get an aggregate and do a join on multiple tables.

For AMO v4, we can just increment the review count, on save of a review - or load this into gearman and do it per addon as needed.
Whiteboard: amov4 workqueue
Severity: normal → enhancement
Priority: -- → P5
Whiteboard: amov4 workqueue → [workqueue]
Target Milestone: --- → 4.x (triaged)
Target Milestone: 4.x (triaged) → 6.0.5
Target Milestone: 6.0.5 → 4.x (triaged)
Assignee: dd → nobody
Well AMO is still running so I am going to assume this isn't a real issue.
Status: NEW → RESOLVED
Last Resolved: 6 years ago
Resolution: --- → WORKSFORME
(Assignee)

Updated

2 years ago
Product: addons.mozilla.org → addons.mozilla.org Graveyard
You need to log in before you can comment on or make changes to this bug.