Skip to content
This repository was archived by the owner on Jun 7, 2023. It is now read-only.

SUS-3263 | FavoriteWikisModel - use rollup_wiki_user_events instead of events_local_users#14274

Merged
macbre merged 6 commits intodevfrom
SUS-3263-FavoriteWikisModel
Nov 22, 2017
Merged

SUS-3263 | FavoriteWikisModel - use rollup_wiki_user_events instead of events_local_users#14274
macbre merged 6 commits intodevfrom
SUS-3263-FavoriteWikisModel

Conversation

@macbre
Copy link
Copy Markdown
Contributor

@macbre macbre commented Nov 22, 2017

https://wikia-inc.atlassian.net/browse/SUS-3263

Let's use rollup_wiki_user_events from Data Engineering instead of events_local_users. We want to get rid of all cross-wiki use cases of the latter table.

The functional difference will be that only the activity from the recent 90 days will be taken into account (instead of since The Beginning Of The Known Universe).

New query

mysql@geo-db-dataware-slave.query.consul[statsdb]>select wiki_id, sum(edits + creates) as edits from rollup_wiki_user_events where period_id = 2 and user_id = 119245 and time_id >= NOW() - INTERVAL 90 DAY group by wiki_id order by edits desc;
+---------+-------+
| wiki_id | edits |
+---------+-------+
| 1474483 |    69 |
|    5915 |    54 |
|  203236 |     6 |
|     177 |     4 |
| 1618258 |     3 |
| 1031256 |     2 |
| 1558829 |     2 |
| 1652920 |     1 |
+---------+-------+
8 rows in set (0.00 sec)

sus-3263

mysql@geo-db-dataware-slave.query.consul[statsdb]>explain select wiki_id, sum(edits + creates) as edits from rollup_wiki_user_events where period_id = 2 and user_id = 119245 and time_id >= NOW() - INTERVAL 90 DAY group by wiki_id order by edits desc;
+----+-------------+-------------------------+-------+--------------------------+------------------+---------+------+------+----------------------------------------------+
| id | select_type | table                   | type  | possible_keys            | key              | key_len | ref  | rows | Extra                                        |
+----+-------------+-------------------------+-------+--------------------------+------------------+---------+------+------+----------------------------------------------+
|  1 | SIMPLE      | rollup_wiki_user_events | range | PRIMARY,period_user_time | period_user_time | 11      | NULL |   23 | Using where; Using temporary; Using filesort |
+----+-------------+-------------------------+-------+--------------------------+------------------+---------+------+------+----------------------------------------------+
1 row in set (0.00 sec)

-- temporary and filesort on 23 rows is not a big deal

$dbr = wfGetDB(DB_SLAVE, [], $wgDWStatsDB );
$where = [
'period_id' => DataMartService::PERIOD_ID_WEEKLY,
'time_id >= NOW() - INTERVAL 90 DAY', // process only recent 90 days
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

INFO Move this trailing comment on the previous empty line. rule

@WikiaTech
Copy link
Copy Markdown

SonarQube analysis reported 1 issue

  • INFO 1 info

Watch the comments in this conversation to review them.

@macbre macbre merged commit e9f2a0f into dev Nov 22, 2017
@macbre macbre deleted the SUS-3263-FavoriteWikisModel branch November 22, 2017 15:31
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants