aboutsummaryrefslogtreecommitdiffstats
path: root/maintenance/rebuildtextindex.inc
diff options
context:
space:
mode:
authornobody <nobody@localhost>2004-06-27 00:05:32 +0000
committernobody <nobody@localhost>2004-06-27 00:05:32 +0000
commit0c1d741ff4792d486258b390cf50cf3f9e229511 (patch)
tree55961c46b433ade0739763bee2ba3c4843d13751 /maintenance/rebuildtextindex.inc
parentd5c8171a3157337557bc54ecb730d7dd35778ca3 (diff)
parent1aaed5fd7c7f4d7ea7abbfc7915bab5954d60a30 (diff)
downloadmediawikicore-1.3.0beta4a.tar.gz
mediawikicore-1.3.0beta4a.zip
This commit was manufactured by cvs2svn to create tag1.3.0beta4a
'REL1_3_0beta4a'.
Diffstat (limited to 'maintenance/rebuildtextindex.inc')
-rw-r--r--maintenance/rebuildtextindex.inc42
1 files changed, 26 insertions, 16 deletions
diff --git a/maintenance/rebuildtextindex.inc b/maintenance/rebuildtextindex.inc
index 65800edf3113..26082263a20a 100644
--- a/maintenance/rebuildtextindex.inc
+++ b/maintenance/rebuildtextindex.inc
@@ -6,40 +6,50 @@
# Rebuilding is faster if you drop the index and recreate it,
# but that will prevent searches from working while it runs.
-function dropTextIndex()
+define( "RTI_CHUNK_SIZE", 500 );
+
+function dropTextIndex( &$database )
{
if ( wfIndexExists( "searchindex", "si_title" ) ) {
echo "Dropping index...\n";
$sql = "ALTER TABLE searchindex DROP INDEX si_title, DROP INDEX si_text";
- $res = wfQuery($sql, DB_WRITE, "dropTextIndex" );
+ $database->query($sql, "dropTextIndex" );
}
+ # Truncate table, in an attempt to bring the slaves to a consistent state
+ # (zwinger was accidentally written to)
+ $database->query( "TRUNCATE TABLE searchindex", "dropTextIndex" );
}
-function createTextIndex()
+function createTextIndex( &$database )
{
echo "Rebuild the index...\n";
$sql = "ALTER TABLE searchindex ADD FULLTEXT si_title (si_title), " .
"ADD FULLTEXT si_text (si_text)";
- $res = wfQuery($sql, DB_WRITE, "createTextIndex" );
+ $database->query($sql, "createTextIndex" );
}
-function rebuildTextIndex()
+function rebuildTextIndex( &$database )
{
- $sql = "SELECT COUNT(*) AS count FROM cur";
- $res = wfQuery($sql, DB_READ, "rebuildTextIndex" );
+ $sql = "SELECT MAX(cur_id) AS count FROM cur";
+ $res = $database->query($sql, "rebuildTextIndex" );
$s = wfFetchObject($res);
- echo "Rebuilding index fields for {$s->count} pages...\n";
+ $count = $s->count;
+ echo "Rebuilding index fields for {$count} pages...\n";
$n = 0;
- $sql = "SELECT cur_id, cur_namespace, cur_title, cur_text FROM cur";
- $res = wfQuery($sql, DB_READ, "rebuildTextIndex" );
-
- while( $s = wfFetchObject($res) ) {
- $u = new SearchUpdate( $s->cur_id, $s->cur_title, $s->cur_text );
- $u->doUpdate();
- if ( ( (++$n) % 500) == 0) { echo "$n\n"; }
+ while ( $n < $count ) {
+ print "$n\n";
+ $end = $n + RTI_CHUNK_SIZE - 1;
+ $sql = "SELECT cur_id, cur_namespace, cur_title, cur_text FROM cur WHERE cur_id BETWEEN $n AND $end";
+ $res = $database->query($sql, "rebuildTextIndex" );
+
+ while( $s = wfFetchObject($res) ) {
+ $u = new SearchUpdate( $s->cur_id, $s->cur_title, $s->cur_text );
+ $u->doUpdate();
+ }
+ wfFreeResult( $res );
+ $n += RTI_CHUNK_SIZE;
}
- wfFreeResult( $res );
}
?>