Use exact counts in updateCollation.php
authorAryeh Gregor <simetrical@users.mediawiki.org>
Tue, 3 Aug 2010 21:11:16 +0000 (21:11 +0000)
committerAryeh Gregor <simetrical@users.mediawiki.org>
Tue, 3 Aug 2010 21:11:16 +0000 (21:11 +0000)
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.

maintenance/updateCollation.php

index 0bc40ec..beea497 100644 (file)
@@ -30,14 +30,18 @@ TEXT;
                global $wgCollationVersion, $wgContLang;
 
                $dbw = wfGetDB( DB_MASTER );
-               $count = $dbw->estimateRowCount(
+               $count = $dbw->selectField(
                        'categorylinks',
-                       array( 'cl_from', 'cl_to', 'cl_sortkey_prefix' ),
+                       'COUNT(*)',
                        'cl_collation != ' . $dbw->addQuotes( $wgCollationVersion ),
                        __METHOD__
                );
 
-               $this->output( "Fixing collation for around $count rows (estimate might be wrong).\n" );
+               if ( $count == 0 ) {
+                       $this->output( "Collations up-to-date.\n" );
+                       return;
+               }
+               $this->output( "Fixing collation for $count rows.\n" );
 
                $count = 0;
                do {