Page MenuHomePhabricator

Special:Ancientpages doesn't use an index
Closed, ResolvedPublic

Description

Author: bugzilla_wikipedia_org.to.jamesd

Description:
Special:Ancientpages has a field "UNIX_TIMESTAMP(cur_timestamp) as value" and
orders by "value". There is no value field in the database so the cur_timestamp
indec in cur can't be used. unix_timestamp and cur_timestamp appear to have the
same order so the query should be changed to order by cur_timestamp insted of by
value. Change from:

EXPLAIN SELECT 'Ancientpages' as type, cur_namespace as namespace, cur_title as
title, UNIX_TIMESTAMP(cur_timestamp) as value FROM cur USE INDEX (cur_timestamp)
WHERE cur_namespace=0 AND cur_is_redirect=0 ORDER BY value LIMIT 1350,250:

  • row 1 *** table: cur type: ALL possible_keys: NULL key: NULL key_len: NULL ref: NULL rows: 382867 Extra: Using where; Using filesort

To:

EXPLAIN SELECT 'Ancientpages' as type, cur_namespace as namespace, cur_title as
title, UNIX_TIMESTAMP(cur_timestamp) as value FROM cur USE INDEX (cur_timestamp)
WHERE cur_namespace=0 AND cur_is_redirect=0 ORDER BY cur_timestamp LIMIT 1350,250:

  • row 1 *** table: cur type: index possible_keys: NULL key: cur_timestamp key_len: 14 ref: NULL rows: 280120 Extra: Using where;

No filesort this time - the key is now being used. This avoids the need to scan
all of cur.


Version: 1.3.x
Severity: normal

Details

Reference
bz600

Event Timeline

bzimport raised the priority of this task from to Medium.Nov 21 2014, 6:57 PM
bzimport set Reference to bz600.
bzimport added a subscriber: Unknown Object (MLST).

domas.mituzas wrote:

I've commited a patch two weeks ago
(http://cvs.defau.lt/phase3/includes/SpecialAncientpages.php), but that's in HEAD.

I don't know what trust do I have, therefore I don't touch live branches.

zigger wrote:

The change was included in the REL1_4 branch.