r79365 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r79364‎ | r79365 | r79366 >
Date:20:24, 31 December 2010
Author:reedy
Status:ok
Tags:
Comment:
Part of bug 24779 CodeReview has many unindexed queries

Override getDefaultSort in CodeRevisionTagView. When not filtered by path, use ct_rev_id rather than cr_id. Improves query no end :)
Modified paths:
  • /trunk/extensions/CodeReview/ui/CodeRevisionListView.php (modified) (history)
  • /trunk/extensions/CodeReview/ui/CodeRevisionTagView.php (modified) (history)

Diff [purge]

Index: trunk/extensions/CodeReview/ui/CodeRevisionListView.php
@@ -244,8 +244,9 @@
245245 }
246246
247247 function getQueryInfo() {
 248+ $defaultSort = $this->getDefaultSort();
248249 // Path-based query...
249 - if ( $this->getDefaultSort() === 'cp_rev_id' ) {
 250+ if ( $defaultSort === 'cp_rev_id' ) {
250251 $query = array(
251252 'tables' => array( 'code_paths', 'code_rev', 'code_comment' ),
252253 'fields' => $this->getSelectFields(),
@@ -255,7 +256,7 @@
256257 // performance
257258 'cp_rev_id > ' . $this->mRepo->getPathSearchHorizon()
258259 ),
259 - 'options' => array( 'GROUP BY' => 'cp_rev_id', 'USE INDEX' => array( 'code_path' => 'cp_repo_id' ) ),
 260+ 'options' => array( 'GROUP BY' => $defaultSort, 'USE INDEX' => array( 'code_path' => 'cp_repo_id' ) ),
260261 'join_conds' => array(
261262 'code_rev' => array( 'INNER JOIN', 'cr_repo_id = cp_repo_id AND cr_id = cp_rev_id' ),
262263 'code_comment' => array( 'LEFT JOIN', 'cc_repo_id = cp_repo_id AND cc_rev_id = cp_rev_id' ),
@@ -267,7 +268,7 @@
268269 'tables' => array( 'code_rev', 'code_comment' ),
269270 'fields' => $this->getSelectFields(),
270271 'conds' => array( 'cr_repo_id' => $this->mRepo->getId() ),
271 - 'options' => array( 'GROUP BY' => 'cr_id' ),
 272+ 'options' => array( 'GROUP BY' => $defaultSort ),
272273 'join_conds' => array(
273274 'code_comment' => array( 'LEFT JOIN', 'cc_repo_id = cr_repo_id AND cc_rev_id = cr_id' ),
274275 )
Index: trunk/extensions/CodeReview/ui/CodeRevisionTagView.php
@@ -17,6 +17,10 @@
1818 $this->mTag = $tag;
1919 }
2020
 21+ function getDefaultSort() {
 22+ return strlen( $this->mView->mPath ) ? 'cp_rev_id' : 'ct_rev_id';
 23+ }
 24+
2125 function getQueryInfo() {
2226 $info = parent::getQueryInfo();
2327 //Don't change table order, see http://www.mediawiki.org/wiki/Special:Code/MediaWiki/77733

Status & tagging log