r70426 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r70425‎ | r70426 | r70427 >
Date:21:11, 3 August 2010
Author:simetrical
Status:ok
Tags:
Comment:
Use exact counts in updateCollation.php

There's no reason to avoid a one-time COUNT(*), is there? It will be
free if collations are actually up-to-date, because the column is
indexed.
Modified paths:
  • /trunk/phase3/maintenance/updateCollation.php (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/updateCollation.php
@@ -30,14 +30,18 @@
3131 global $wgCollationVersion, $wgContLang;
3232
3333 $dbw = wfGetDB( DB_MASTER );
34 - $count = $dbw->estimateRowCount(
 34+ $count = $dbw->selectField(
3535 'categorylinks',
36 - array( 'cl_from', 'cl_to', 'cl_sortkey_prefix' ),
 36+ 'COUNT(*)',
3737 'cl_collation != ' . $dbw->addQuotes( $wgCollationVersion ),
3838 __METHOD__
3939 );
4040
41 - $this->output( "Fixing collation for around $count rows (estimate might be wrong).\n" );
 41+ if ( $count == 0 ) {
 42+ $this->output( "Collations up-to-date.\n" );
 43+ return;
 44+ }
 45+ $this->output( "Fixing collation for $count rows.\n" );
4246
4347 $count = 0;
4448 do {

Status & tagging log