Fix slow queries in migrateActors.php
authorBrad Jorsch <bjorsch@wikimedia.org>
Mon, 17 Dec 2018 17:26:13 +0000 (12:26 -0500)
committerBrad Jorsch <bjorsch@wikimedia.org>
Mon, 17 Dec 2018 17:33:39 +0000 (12:33 -0500)
commit117a6c51f2fad6f6395df742c404a359e31185fb
tree57ac1f89d51b46c64ecdb7db3f44ed54e176d3f0
parent55016be767cf7511f5ad87b067f0a8203b015357
Fix slow queries in migrateActors.php

MariaDB really doesn't like the complicated OR in the join condition for
the actor table, it winds up scanning the whole actor table to find the
match. After trying several different options, the best bet seems to be
to use subqueries to get the actor_id.

MariaDB also doesn't like the DISTINCTed query for log_search, it gets
confused if the selected fields contain other fields much like it
historically gets confused when GROUP BY contains fields that are
constant in the WHERE clause. So we'll do the select from log_search in
a subquery and then join with actor, and inject the constant ls_field
into the rows as a constant field.

Bug: T188327
Change-Id: I979c040441f83bdf36e2f4031152559391233e5f
maintenance/migrateActors.php