jenkins-bot has submitted this change and it was merged. Change subject: Add index for mycontribs hook ......................................................................
Add index for mycontribs hook Lack of this index resulted in "most apache children were tied up waiting on queries to the slave in that shard" "I checked explains for a few of the queries and those that I picked weren't covered by any index (i.e. searching for feedback by ip address on aft_user_text which is unindexed) and all included an ORDER BY + LIMIT. Not bad if that's covered by an index, not good if the query can't use one." Query this index is meant for: public function getContributionsData( $pager, $offset, $limit, $descending, $userIds = array() ) { $tables[] = 'aft_feedback'; $fields[] = 'aft_id'; $fields[] = 'aft_page'; $fields[] = '"AFT" AS aft_contribution'; $fields[] = 'aft_timestamp AS ' . $pager->getIndexField(); // used for navbar if ( $pager->contribs == 'newbie' ) { $conds['aft_user'] = $userIds; } else { $uid = User::idFromName( $pager->target ); if ( $uid ) { $conds['aft_user'] = $uid; } else { $conds['aft_user'] = 0; $conds['aft_user_text'] = $pager->target; } } if ( $offset ) { $operator = $descending ? '>' : '<'; $conds[] = "aft_timestamp $operator " . $pager->getDatabase()->addQuotes( $offset ); } $order = $descending ? 'ASC' : 'DESC'; // something's wrong with $descending - see logic applied in includes/Pager.php $options['ORDER BY'] = array( $pager->getIndexField() . " $order" ); $options['LIMIT'] = $limit; return $this->getDB( DB_SLAVE )->select( $tables, $fields, $conds, __METHOD__, $options, array() ); } Change-Id: I330be208dc1e752a71339a97cd810dd6eaa4c4c6 --- M ArticleFeedbackv5.hooks.php M sql/ArticleFeedbackv5.sql A sql/index_contribs.sql 3 files changed, 12 insertions(+), 0 deletions(-) Approvals: Lwelling: Looks good to me, approved jenkins-bot: Verified diff --git a/ArticleFeedbackv5.hooks.php b/ArticleFeedbackv5.hooks.php index 7911c21..3eb23f7 100644 --- a/ArticleFeedbackv5.hooks.php +++ b/ArticleFeedbackv5.hooks.php @@ -73,6 +73,12 @@ dirname( __FILE__ ) . '/sql/inappropriate.sql' ); + $updater->addExtensionIndex( + 'aft_feedback', + 'contribs', + dirname( __FILE__ ) . '/sql/index_contribs.sql' + ); + return true; } diff --git a/sql/ArticleFeedbackv5.sql b/sql/ArticleFeedbackv5.sql index 1aca8fa..726eaf3 100644 --- a/sql/ArticleFeedbackv5.sql +++ b/sql/ArticleFeedbackv5.sql @@ -39,3 +39,7 @@ -- index for archive-job CREATE INDEX /*i*/archive_queue ON /*_*/aft_feedback (aft_archive, aft_archive_date); + +-- index for mycontribs data +CREATE INDEX /*i*/contribs ON /*_*/aft_feedback (aft_user, aft_timestamp); +CREATE INDEX /*i*/contribs_anon ON /*_*/aft_feedback (aft_user, aft_user_text, aft_timestamp); diff --git a/sql/index_contribs.sql b/sql/index_contribs.sql new file mode 100644 index 0000000..f8142a9 --- /dev/null +++ b/sql/index_contribs.sql @@ -0,0 +1,2 @@ +CREATE INDEX /*i*/contribs ON /*_*/aft_feedback (aft_user, aft_timestamp); +CREATE INDEX /*i*/contribs_anon ON /*_*/aft_feedback (aft_user, aft_user_text, aft_timestamp); -- To view, visit https://gerrit.wikimedia.org/r/54108 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I330be208dc1e752a71339a97cd810dd6eaa4c4c6 Gerrit-PatchSet: 4 Gerrit-Project: mediawiki/extensions/ArticleFeedbackv5 Gerrit-Branch: master Gerrit-Owner: Matthias Mullie <mmul...@wikimedia.org> Gerrit-Reviewer: Asher <afeld...@wikimedia.org> Gerrit-Reviewer: Lwelling <lwell...@wikimedia.org> Gerrit-Reviewer: Matthias Mullie <mmul...@wikimedia.org> Gerrit-Reviewer: jenkins-bot _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits