Author: bugzilla_wikipedia_org.to.jamesd
Description:
This causes a full table scan of several gigabytes of data,
much of which isn't cached, and regularly takes more than a
minute for de and hundreds of seconds for en. Please change
it to use the query below, which uses an index which is
normally very well cached because it's used for lots of
article lookups.
select count(cur_namespace) from cur;
+----------------------+
count(cur_namespace) |
+----------------------+
1292372 |
+----------------------+
1 row in set (6.29 sec)
mysql> explain select count(cur_namespace) from cur;
+-------+-------+---------------+----------------------+-----
----+------+---------+-------------+
table | type | possible_keys | key | |
key_len | ref | rows | Extra |
+-------+-------+---------------+----------------------+-----
----+------+---------+-------------+
cur | index | NULL | name_title_timestamp | |
270 | NULL | 1444561 | Using index |
+-------+-------+---------------+----------------------+-----
----+------+---------+-------------+
1 row in set (0.00 sec)
Next run takes 0.62 seconds. Current code causes results
like this on bacon:
1548197 wikiuser igoeje:53107 enwiki 402
Query /* wfSpecialStatistics */ SELECT COUNT(cur_id) AS
total FROM cur
or this on holbach:
23994523 wikiuser smellie:33404 dewiki 112
Query /* wfSpecialStatistics */ SELECT COUNT(cur_id) AS
total FROM cur
Because of the long run time and high disk activity these
queries are also a regular cause of replication lag. It's
also fairly common to see several of these running at the
same time for wikis like en and de.
The smaller cur records for 1.5 will help these queries but
it'll still be better to have this index used.
Version: 1.4.x
Severity: normal