From: Aaron Schulz Date: Tue, 23 Feb 2016 00:56:36 +0000 (-0800) Subject: Avoid pointless doBatchLookups() query for user contributions X-Git-Tag: 1.31.0-rc.0~7860^2 X-Git-Url: https://git.cyclocoop.org/%7B%24admin_url%7Dmembres/%7B%7B%20url_for%28%27vote%27%2C%20idvote=vote.voteid%29%20%7D%7D?a=commitdiff_plain;h=69ca735c69d282d30517d79fdba803189f268ce2;p=lhc%2Fweb%2Fwiklou.git Avoid pointless doBatchLookups() query for user contributions This shows up in slow query reports a lot. Change-Id: Ic1cf45fae87655e0b9d09fdc96aa2b2c22de2c11 --- diff --git a/includes/specials/SpecialContributions.php b/includes/specials/SpecialContributions.php index 254d9e2401..5a351a7967 100644 --- a/includes/specials/SpecialContributions.php +++ b/includes/specials/SpecialContributions.php @@ -934,14 +934,16 @@ class ContribsPager extends ReverseChronologicalPager { function doBatchLookups() { # Do a link batch query $this->mResult->seek( 0 ); - $revIds = []; + $parentRevIds = []; + $this->mParentLens = []; $batch = new LinkBatch(); # Give some pointers to make (last) links foreach ( $this->mResult as $row ) { if ( isset( $row->rev_parent_id ) && $row->rev_parent_id ) { - $revIds[] = $row->rev_parent_id; + $parentRevIds[] = $row->rev_parent_id; } if ( isset( $row->rev_id ) ) { + $this->mParentLens[$row->rev_id] = $row->rev_len; if ( $this->contribs === 'newbie' ) { // multiple users $batch->add( NS_USER, $row->user_name ); $batch->add( NS_USER_TALK, $row->user_name ); @@ -949,7 +951,11 @@ class ContribsPager extends ReverseChronologicalPager { $batch->add( $row->page_namespace, $row->page_title ); } } - $this->mParentLens = Revision::getParentLengths( $this->mDbSecondary, $revIds ); + # Fetch rev_len for revisions not already scanned above + $this->mParentLens += Revision::getParentLengths( + $this->mDbSecondary, + array_diff( $parentRevIds, array_keys( $this->mParentLens ) ) + ); $batch->execute(); $this->mResult->seek( 0 ); }