Last modified: 2014-02-10 08:31:09 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T43078, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 41078 - Special:ActiveUsers query is very slow
Special:ActiveUsers query is very slow
Status: RESOLVED FIXED
Product: MediaWiki
Classification: Unclassified
Special pages (Other open bugs)
1.21.x
All All
: Normal normal with 2 votes (vote)
: ---
Assigned To: Aaron Schulz
: performance
: 46938 47559 (view as bug list)
Depends on:
Blocks: 39480 29572
  Show dependency treegraph
 
Reported: 2012-10-16 11:27 UTC by Niklas Laxström
Modified: 2014-02-10 08:31 UTC (History)
25 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments

Description Niklas Laxström 2012-10-16 11:27:05 UTC
On profiling it is taking 123s on average, on my test it took over 40s on translatewiki.net.

Truncated query:
query: SELECT rc_user_text AS user_name,rc_user_text,user_id,COUNT(*) AS recentedits,MAX(ipb_deleted) AS ipb_deleted FROM `bw_recentchanges` FORCE INDEX (rc_user_text) INNER JOIN `bw_user` ON ((rc_user_text=user_name)) LEFT JOIN `bw_ipblocks` ON ((user_id
Comment 2 Sam Reed (reedy) 2012-10-17 18:28:20 UTC
Need to grab a full SQL query and run EXPLAIN on it....
Comment 3 Sam Reed (reedy) 2012-10-17 18:30:10 UTC
Query wikidb (23) (slave):

SELECT /* IndexPager::buildQueryInfo (ActiveUsersPager) Reedy */  rc_user_text AS user_name,rc_user_text,user_id,COUNT(*) AS recentedits,MAX(ipb_deleted) AS ipb_deleted  FROM `mw_recentchanges` FORCE INDEX (rc_user_text) INNER JOIN `mw_user` ON ((rc_user_text=user_name)) LEFT JOIN `mw_ipblocks` ON ((user_id=ipb_user) AND ipb_auto = '0')  WHERE (rc_user > 0) AND (ipb_deleted IS NULL OR ipb_deleted = 0) AND (rc_log_type IS NULL OR rc_log_type != 'newusers') AND (rc_timestamp > '20120917182934')
Comment 4 Sam Reed (reedy) 2012-10-17 18:31:14 UTC
mysql> explain SELECT /* IndexPager::buildQueryInfo (ActiveUsersPager) Reedy */  rc_user_text AS user_name,rc_user_text,user_id,COUNT(*) AS recentedits,MAX(ipb_deleted) AS ipb_deleted  FROM `recentchanges` FORCE INDEX (rc_user_text) INNER JOIN `user` ON ((rc_user_text=user_name)) LEFT JOIN `ipblocks` ON ((user_id=ipb_user) AND ipb_auto = '0')  WHERE (rc_user > 0) AND (ipb_deleted IS NULL OR ipb_deleted = 0) AND (rc_log_type IS NULL OR rc_log_type != 'newusers') AND (rc_timestamp > '20120917182934');
+----+-------------+---------------+--------+---------------+-----------+---------+------------------------------------------+-------+-------------+
| id | select_type | table         | type   | possible_keys | key       | key_len | ref                                      | rows  | Extra       |
+----+-------------+---------------+--------+---------------+-----------+---------+------------------------------------------+-------+-------------+
|  1 | SIMPLE      | recentchanges | ALL    | rc_user_text  | NULL      | NULL    | NULL                                     | 11096 | Using where |
|  1 | SIMPLE      | user          | eq_ref | user_name     | user_name | 257     | mediawikiwiki.recentchanges.rc_user_text |     1 | Using index |
|  1 | SIMPLE      | ipblocks      | ref    | ipb_user      | ipb_user  | 4       | mediawikiwiki.user.user_id               |     1 | Using where |
+----+-------------+---------------+--------+---------------+-----------+---------+------------------------------------------+-------+-------------+
3 rows in set (0.01 sec)
Comment 5 Niklas Laxström 2012-10-17 21:33:07 UTC
I guess the problem is recentchanges table which is not using index. It's scanning millions of row in translatewiki.net
Comment 8 Niklas Laxström 2012-10-17 22:34:53 UTC
Makes only marginal difference:

101 rows in set (35.61 sec)

mysql> explain SELECT /* IndexPager::buildQueryInfo (ActiveUsersPager) Nike */  rc_user_text AS user_name,rc_user_text,user_id,COUNT(*) AS recentedits,MAX(ipb_user) AS blocked  FROM `bw_recentchanges` FORCE INDEX (rc_user_text) INNER JOIN `bw_user` ON ((rc_user_text=user_name)) LEFT JOIN `bw_ipblocks` ON ((user_id=ipb_user) AND ipb_auto = '0' AND ipb_deleted = '1')  WHERE (rc_user > 0) AND (ipb_deleted IS NULL) AND (rc_log_type IS NULL OR rc_log_type != 'newusers') AND (rc_timestamp >= '20120917223021')  GROUP BY rc_user_text,user_id ORDER BY rc_user_text LIMIT 101;
+----+-------------+------------------+--------+---------------+--------------+---------+-----------------------------------------+--------+-------------------------+
| id | select_type | table            | type   | possible_keys | key          | key_len | ref                                     | rows   | Extra                   |
+----+-------------+------------------+--------+---------------+--------------+---------+-----------------------------------------+--------+-------------------------+
|  1 | SIMPLE      | bw_recentchanges | index  | rc_user_text  | rc_user_text | 273     | NULL                                    | 155136 | Using where             |
|  1 | SIMPLE      | bw_user          | eq_ref | user_name     | user_name    | 257     | mediawiki.bw_recentchanges.rc_user_text |      1 | Using index             |
|  1 | SIMPLE      | bw_ipblocks      | ref    | ipb_user      | ipb_user     | 4       | mediawiki.bw_user.user_id               |      1 | Using where; Not exists |
+----+-------------+------------------+--------+---------------+--------------+---------+-----------------------------------------+--------+-------------------------+
3 rows in set (0.01 sec)
Comment 9 Umherirrender 2012-10-19 16:37:20 UTC
That pages was slow on translatewiki before my changes, because translatewiki has set RCMaxAge to a high value and that result in many rows in the recentchange table.

It is hard to say, which query will give the best result for this.
Comment 10 Sam Reed (reedy) 2012-10-19 17:19:28 UTC
(In reply to comment #9)
> That pages was slow on translatewiki before my changes, because translatewiki
> has set RCMaxAge to a high value and that result in many rows in the
> recentchange table.
> 
> It is hard to say, which query will give the best result for this.

It just seemed a likely candidate as it had been deployed, then it was noticed it was slow. Granted, it's not that commit.

Reverted https://gerrit.wikimedia.org/r/#/c/28689/
Comment 11 Andre Klapper 2013-01-15 16:07:14 UTC
Can this problem still be seen?
Comment 12 Sam Reed (reedy) 2013-01-15 16:18:22 UTC
http://translatewiki.net/wiki/Special:ActiveUsers

It's certainly not fast...

<!-- Served in 12.943 secs. -->



Less than half a second on enwiki
Comment 13 Umherirrender 2013-03-15 13:44:11 UTC
query reduced with Gerrit change #51290
Comment 14 Nemo 2013-03-15 14:36:15 UTC
(In reply to comment #12)
> <!-- Served in 12.943 secs. -->

(In reply to comment #13)
> query reduced with Gerrit change #51290

-rakkaus:#mediawiki-i18n- [nike] updated translatewiki.net to 7ca8090 2013-03-15 14:32:34 +0000 (45 seconds ago)

Now:
<!-- Served in 7.325 secs. -->
<!-- Served in 6.851 secs. -->
Comment 15 db [inactive,noenotif] 2013-03-26 20:08:08 UTC
special page was removed with Gerrit change #55807
Comment 16 Ankry 2013-04-05 22:46:53 UTC
Please revert this change.

This page is (was?) very useful on many small and even medium wikis with relatively low number of edits and it was not a performance hit there.
The summarized, up-to-date information about active users or even a list of active users is very useful.
If there is a performance problem on some wikis (translatewiki?) it should be solved in a per-wiki way. I see at least three ways:

1. limit time period or number of analyzed edits

2. use some caching/locking to avoid this call be called too often

3. disable it in per-wiki way only on wikis where a problem occurs

Or, at least, offer an alternative while removing this page.
Comment 17 Bartosz Dziewoński 2013-04-05 22:56:20 UTC
(CC-ing code submitter and reviewers.)
Comment 18 Aaron Schulz 2013-04-05 23:03:33 UTC
One thing that slowed it down was showing the count of the recent edits (an expensive GROUP BY). It could have used a LIMIT 10 subquery for each or just not have that count at all and maybe just use user_editcount (total edits, recent or not).
Comment 19 Bartosz Dziewoński 2013-04-06 19:35:10 UTC
*** Bug 46938 has been marked as a duplicate of this bug. ***
Comment 20 Tom H 2013-04-07 01:47:09 UTC
(In reply to comment #16)
> Please revert this change.
> 
> This page is (was?) very useful on many small and even medium wikis with
> relatively low number of edits and it was not a performance hit there.
> The summarized, up-to-date information about active users or even a list of
> active users is very useful.
> If there is a performance problem on some wikis (translatewiki?) it should be
> solved in a per-wiki way. I see at least three ways:
> 
> 1. limit time period or number of analyzed edits
> 
> 2. use some caching/locking to avoid this call be called too often
> 
> 3. disable it in per-wiki way only on wikis where a problem occurs
> 
> Or, at least, offer an alternative while removing this page.

+1 on this revert. 

I'm sorry, but it was a 'axe it' mentality based load on wikipedia because of its unique - large data set. If the query is trash, tweak or improve it. Pull it from somewhere else. Too many smaller wikis rely on what is already a small set of metric data for Mediawiki. Rate limit it, cache it or allow for disabling with a boolean switch.
Comment 21 MZMcBride 2013-04-07 17:36:26 UTC
If the addition of this feature was "poorly thought out," surely its removal had even less consideration. Looking at <https://gerrit.wikimedia.org/r/55807>, was this feature really removed in just 20 minutes? Won't this be a breaking change in the MediaWiki API (among the other ripple effects)?

(In reply to comment #12)
> http://translatewiki.net/wiki/Special:ActiveUsers
> 
> It's certainly not fast...
> 
> <!-- Served in 12.943 secs. -->

So on the wiki that set its "recent changes" to be _years_, it's slightly slow. On a giant production database, however...

> Less than half a second on enwiki

This really justified removing the feature in the course of an hour? I'm a bit baffled here.
Comment 22 Niklas Laxström 2013-04-07 17:47:55 UTC
It was slow on WMF too:

[23:45:38]  binasher> ^demon: i noticed that one of the enwiki slaves was lagging a bunch and getting a bunch of ActiveUsersPager queries.. looks like an uncommonly called page, but the query results in just about a full scan                       of recentchanges with an on disk temp table
[23:46:03]  binasher> takes around 2 minutes on a busy server if all pages are in the bufferpool
[23:46:08]  binasher> and 8 if not
Comment 23 Ravishankar 2013-04-11 12:26:08 UTC
Hi, 

We have been using this metric in Tamil Wikipedia to identify and encourage new and active users. Can we get this feature back, please? At least, you can switch this on and off per wiki or provide an option to run this through extensions. 

Thanks.
Comment 24 Oleg 2013-04-12 14:50:53 UTC
+1 to Ravishankar. In Lezgi Wikipedia we have the rules of administrators election - voter must have at least 10 edits in the «Articles», «Templates» and/or «Category» namespaces within the last 30 days.
Comment 25 Rainer Rillke @commons.wikimedia 2013-04-13 10:48:52 UTC
I wonder, why I didn't read it in the wikitech-ambassadors mailing list. Perhaps this change was just not submitted to that mailing list?
Comment 26 MZMcBride 2013-04-18 04:03:42 UTC
(In reply to comment #25)
> I wonder, why I didn't read it in the wikitech-ambassadors mailing list.
> Perhaps this change was just not submitted to that mailing list?

Related: bug 47350 ("Restore Special:ActiveUsers prior to the release of MediaWiki 1.21")
Comment 27 Bawolff (Brian Wolff) 2013-04-21 14:41:39 UTC
If the query really is that slow, could be re-done as a cached special page perhaps.
Comment 28 Bawolff (Brian Wolff) 2013-04-23 17:20:24 UTC
*** Bug 47559 has been marked as a duplicate of this bug. ***
Comment 29 db [inactive,noenotif] 2013-05-10 15:55:48 UTC
(In reply to comment #15)
> special page was removed with Gerrit change #55807

Back with Gerrit change #58686


Gerrit change #62408 refactored the query. Please test if this helps with the performance. Thanks.
Comment 30 Niklas Laxström 2013-05-11 07:03:55 UTC
Serves in about one second on translatewiki.net now. Should we close this bug now?
Comment 31 Nemo 2013-05-11 08:55:15 UTC
(In reply to comment #30)
> Serves in about one second on translatewiki.net now. Should we close this bug
> now?

Probably. On the other hand, it should be restored on en.wiki with 1.22wmf4 on Monday, May 20, 2013, so we could as well wait a week and see.
Comment 32 Oleg 2013-05-11 10:23:10 UTC
Restore Active Users in small Wikipedias! The decision to remove it was harmful for small Wikis!
Comment 33 Nemo 2013-05-11 10:29:51 UTC
(In reply to comment #32)
> Restore Active Users in small Wikipedias! The decision to remove it was
> harmful
> for small Wikis!

As I said, it's going to be restored on all wikis (and then disabled again on some wikis if needed). See the calendar for 1.22wmf4 code update: https://www.mediawiki.org/wiki/MediaWiki_1.22/Roadmap
Comment 34 Umherirrender 2013-05-23 17:41:35 UTC
All wikis now on 1.22wmf4, it is still active on enwiki, looks like the new query is not slow anymore -> FIXED
Comment 35 Aaron Schulz 2013-05-23 17:52:16 UTC
(In reply to comment #34)
> All wikis now on 1.22wmf4, it is still active on enwiki, looks like the new
> query is not slow anymore -> FIXED

It's still sometimes slow for enwiki/wikidatawiki, not sure exactly why though.
Comment 36 Nemo 2013-05-23 18:00:00 UTC
For the records, on en.wiki it's now like this:

Served by mw1022 in 0.453 secs.
Served by mw1077 in 0.343 secs.
Served by mw1043 in 0.467 secs.
Comment 37 MZMcBride 2013-05-24 03:17:09 UTC
Query cache and other caching layers likely affect any attempts at benchmarking.
Comment 38 Gerrit Notification Bot 2014-02-02 17:35:08 UTC
Change 110299 had a related patch set uploaded by Nemo bis:
Made ActiveUsers use querycache and do staggered updates on view

https://gerrit.wikimedia.org/r/110299
Comment 39 Gerrit Notification Bot 2014-02-04 20:22:46 UTC
Change 110299 merged by jenkins-bot:
Made ActiveUsers use querycache and do staggered updates on view

https://gerrit.wikimedia.org/r/110299
Comment 40 Gerrit Notification Bot 2014-02-04 20:43:04 UTC
Change 111258 had a related patch set uploaded by Aaron Schulz:
Made ActiveUsers use querycache and do staggered updates on view

https://gerrit.wikimedia.org/r/111258
Comment 41 Gerrit Notification Bot 2014-02-04 20:48:10 UTC
Change 111258 merged by jenkins-bot:
Made ActiveUsers use querycache and do staggered updates on view

https://gerrit.wikimedia.org/r/111258

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links