jenkins-bot has submitted this change and it was merged. Change subject: Fix slow Rolling Active Editor metric ......................................................................
Fix slow Rolling Active Editor metric There was a performance mistake in the previous version of the query. The query was filtering on users only after collecting data from the revision and archive tables. Filtering on users closer to the subqueries against revision and archive tables speeds up execution a lot because there of the indices on rev_user and ar_user. Bug: 68596 Change-Id: Id992ee2030d6257eb681dff2cf4246750097f9af --- M wikimetrics/metrics/rolling_active_editor.py 1 file changed, 3 insertions(+), 3 deletions(-) Approvals: Nuria: Looks good to me, approved Milimetric: Looks good to me, but someone else must approve jenkins-bot: Verified Objections: QChris: There's a problem with this change, please improve diff --git a/wikimetrics/metrics/rolling_active_editor.py b/wikimetrics/metrics/rolling_active_editor.py index 3726f74..7897af0 100644 --- a/wikimetrics/metrics/rolling_active_editor.py +++ b/wikimetrics/metrics/rolling_active_editor.py @@ -86,10 +86,12 @@ revisions = session.query(rev_user, count)\ .filter(between(Revision.rev_timestamp, start_date, end_date))\ .group_by(Revision.rev_user) + revisions = self.filter(revisions, user_ids, column=Revision.rev_user) archived = session.query(ar_user, count)\ .filter(between(Archive.ar_timestamp, start_date, end_date))\ .group_by(Archive.ar_user) + archived = self.filter(archived, user_ids, column=Archive.ar_user) edits = revisions.union_all(archived).subquery() edits_by_user = session.query( @@ -98,9 +100,7 @@ )\ .group_by(edits.c.user_id) - metric = self.filter(edits_by_user, user_ids, column=edits.c.user_id) - - metric_results = {r[0]: {self.id : r[1]} for r in metric.all()} + metric_results = {r[0]: {self.id : r[1]} for r in edits_by_user.all()} if user_ids is None: return metric_results -- To view, visit https://gerrit.wikimedia.org/r/149482 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: Id992ee2030d6257eb681dff2cf4246750097f9af Gerrit-PatchSet: 4 Gerrit-Project: analytics/wikimetrics Gerrit-Branch: master Gerrit-Owner: Milimetric <dandree...@wikimedia.org> Gerrit-Reviewer: Milimetric <dandree...@wikimedia.org> Gerrit-Reviewer: Nuria <nu...@wikimedia.org> Gerrit-Reviewer: QChris <christ...@quelltextlich.at> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits