SpecialContributions::doBatchLookups() calls Revision::getParentLengths() like this:
Revision::getParentLengths( $this->getDatabase(), $revIds );
getDatabase returns $this->mDb which is set in the SpecialContributions constructor using 'contributions' to identify it to the database load balancer:
$this->mDb = wfGetDB( DB_SLAVE, 'contributions' );
Passing mDb to getParentLengths is not ideal as the query type is quite different and limits what can be done in the backend. Consider passing a normal unnamed slave connection instead.
On WMF production shards mDb is usually a connection to a slave set aside for special queries on a shard. One of the possible optimizations that can be applied to such slaves is table partitioning based on range or hash of rev_user (this approach is proving effective for the similar LogPager queries).
Unfortunately partitioning increases the cost of some other types of queries including the huge batched lookups generated by getParentLengths. It would be nice to have the best of both worlds.
Version: 1.23.0
Severity: normal