r94671 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r94670‎ | r94671 | r94672 >
Date:18:09, 16 August 2011
Author:demon
Status:resolved (Comments)
Tags:
Comment:
Minor tweaks to r94419: make batch size configurable, use RUN_MAINTENANCE_IF_MAIN
Modified paths:
  • /trunk/extensions/TitleKey/rebuildTitleKeys.php (modified) (history)

Diff [purge]

Index: trunk/extensions/TitleKey/rebuildTitleKeys.php
@@ -15,6 +15,7 @@
1616 function __construct() {
1717 parent::__construct();
1818 $this->mDescription = "Rebuilds titlekey table entries for all pages in DB.";
 19+ $this->mBatchSize = 1000;
1920 $this->addOption( 'start', 'Page ID to start from', false, true );
2021 }
2122
@@ -24,10 +25,9 @@
2526 $dbr = $this->getDB( DB_SLAVE );
2627
2728 $maxId = $dbr->selectField( 'page', 'MAX(page_id)', '', __METHOD__ );
28 - $chunkSize = 1000;
2929
3030 $lastId = 0;
31 - for( ; $start <= $maxId; $start += $chunkSize ) {
 31+ for( ; $start <= $maxId; $start += $this->mBatchSize ) {
3232 if( $start != 0 ) {
3333 $this->output( "... $start...\n" );
3434 }
@@ -37,7 +37,7 @@
3838 __METHOD__,
3939 array(
4040 'ORDER BY' => 'page_id',
41 - 'LIMIT' => $chunkSize ) );
 41+ 'LIMIT' => $this->mBatchSize ) );
4242
4343 $titles = array();
4444 foreach( $result as $row ) {
@@ -60,4 +60,4 @@
6161 }
6262
6363 $maintClass = 'RebuildTitleKeys';
64 -require_once( DO_MAINTENANCE );
 64+require_once( RUN_MAINTENANCE_IF_MAIN );

Follow-up revisions

RevisionCommit summaryAuthorDate
r95811Followup r94671: use setBatchSize() instead of $mBatchSize so its less confusingdemon20:48, 30 August 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r94419* Made rebuildTitleKeys.php script use Maintenance class...ialex16:14, 13 August 2011

Comments

#Comment by Brion VIBBER (talk | contribs)   23:00, 16 August 2011

I see nothing settable in the command-line settings...

#Comment by 😂 (talk | contribs)   23:35, 16 August 2011

That's what $mBatchSize is for. I probably should've used setBatchSize() for clarity.

#Comment by Brion VIBBER (talk | contribs)   00:26, 17 August 2011

Hmm... so that's configurable by running maintenance/eval.php, instantiating the Maintenance subclass, and making some calls on it?

#Comment by 😂 (talk | contribs)   20:50, 30 August 2011

When $mBatchSize is set, it adds it to the command line arguments and allows you to override it. I used setBatchSize() in the followup so it's less confusing :)

#Comment by Brion VIBBER (talk | contribs)   18:19, 31 August 2011

Excellent, I can see it now in --help output:

   --batch-size: Run this many operations per batch, default: 1000

It all makes sense now :D

Status & tagging log