ContribsPager: Fix slow queries
authorBrad Jorsch <bjorsch@wikimedia.org>
Tue, 23 Apr 2019 16:13:08 +0000 (12:13 -0400)
committerBrad Jorsch <bjorsch@wikimedia.org>
Wed, 1 May 2019 01:07:32 +0000 (21:07 -0400)
commitc1db9d74430a8038766a62d32e06135aceb05c21
treefbf638b6cbd5fadc3c774a628f67ad654a4c6e82
parent85c5164bab1d530f9e26d2967439bd47059c9b80
ContribsPager: Fix slow queries

When ContribsPager is using an auxiliary table like ip_changes or
revision_actor_temp for the main action of the query, we already had
code in place to let it use the auxiliary table's denormalized timestamp
field for the ordering. What we didn't have was code to let it also use
the auxiliary table's denormalized timestamp field for *continuation*.

With the schema defined in tables.sql, the simplest thing to do would be
to be to add a redundant JOIN condition between rev_timestamp and the
denormalized timestamp field which would be enough to allow
MySQL/MariaDB to propagate the continuation conditional on rev_timestamp
to the denormalized timestamp field.

Unfortunately many Wikimedia wikis have rev_timestamp defined
differently from table.sql (P8433), and that difference is enough to
break that propagation. So we need to take a more difficult route,
restructuring the code tell IndexPager to explicitly use the
denormalized fields for ordering and continuation.

On the plus side, since we're doing that anyway we can get rid of the
code mentioned in the first paragraph.

Bug: T221380
Change-Id: Iad6c0c2f1ac5e1c610de15fe6e85a637c287bcd8
includes/specials/pagers/ContribsPager.php
tests/phpunit/includes/specials/ContribsPagerTest.php