r57027 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r57026‎ | r57027 | r57028 >
Date:21:41, 28 September 2009
Author:aaron
Status:ok
Tags:
Comment:
Query optimizations
Modified paths:
  • /trunk/extensions/FlaggedRevs/maintenance/updateStats.inc (modified) (history)

Diff [purge]

Index: trunk/extensions/FlaggedRevs/maintenance/updateStats.inc
@@ -138,17 +138,9 @@
139139 }
140140 # Sanity check the starting timestamp
141141 $minTS = max($minTS,$installed);
142 - # Get correspond rev_ids to boundaries
 142+ # Get timestamp boundaries
143143 $timeCondition = 'rev_timestamp BETWEEN '.$dbr->addQuotes($minTS).' AND '.$dbr->addQuotes($maxTS);
144 - $minRev = (int)$dbr->selectField( 'revision', 'rev_id',
145 - array( $timeCondition, 'rev_user' => 0 ),
146 - __METHOD__, array( 'ORDER BY' => 'rev_timestamp ASC' )
147 - );
148 - $maxRev = (int)$dbr->selectField( 'revision', 'rev_id',
149 - array( $timeCondition, 'rev_user' => 0 ),
150 - __METHOD__, array( 'ORDER BY' => 'rev_timestamp DESC' )
151 - );
152 - # Modulus
 144+ # Modulus (to spread out over range)
153145 $mod = intval($rows/$size);
154146 $mod = max($mod,1); # $mod >= 1
155147 # For edits that started off pending, how long do they take to get reviewed?
@@ -158,7 +150,6 @@
159151 array( 'UNIX_TIMESTAMP(rev_timestamp) AS rt', 'UNIX_TIMESTAMP(MIN(fr_timestamp)) AS ft', 'MIN(log_timestamp)' ),
160152 array(
161153 $timeCondition, // in time range
162 - "rev_id BETWEEN $minRev AND $maxRev", // Better INDEX usage
163154 'rev_user = 0', // IP edits (should start off unreviewed)
164155 "(rev_id % $mod) = 0", // Better spread
165156 ),
@@ -176,7 +167,7 @@
177168 'logging' => array('INNER JOIN','log_namespace = page_namespace AND log_title = page_title
178169 AND log_type = "review" AND log_timestamp < rev_timestamp'),
179170 // Check *if* it was later reviewed
180 - 'flaggedrevs' => array('LEFT JOIN', 'fr_page_id = rev_page AND fr_rev_id >= rev_id AND fr_timestamp > rev_timestamp'),
 171+ 'flaggedrevs' => array('LEFT JOIN', 'fr_page_id = page_id AND fr_rev_id >= rev_id AND fr_timestamp > rev_timestamp'),
181172 )
182173 );
183174 # Actually run the query...

Follow-up revisions

RevisionCommit summaryAuthorDate
r57028merged r57027aaron21:42, 28 September 2009

Status & tagging log