diff --git a/ecrire/inc_base.php3 b/ecrire/inc_base.php3
index e16bd6d01a0ec1dfa0ff820d384f9c154afbb65f..41c9c663f162e23ba5bb31b3d8a440397cbde766 100644
--- a/ecrire/inc_base.php3
+++ b/ecrire/inc_base.php3
@@ -241,11 +241,12 @@ function creer_base() {
 		id_message bigint(21) DEFAULT '0' NOT NULL,
 		id_syndic bigint(21) DEFAULT '0' NOT NULL,
 		PRIMARY KEY (id_forum),
-		KEY id_parent(id_parent),
-		KEY id_rubrique(id_rubrique),
-		KEY id_article(id_article),
-		KEY id_breve(id_breve),
-		KEY id_message(id_message),
+		KEY id_parent (id_parent),
+		KEY id_rubrique (id_rubrique),
+		KEY id_article (id_article),
+		KEY id_breve (id_breve),
+		KEY id_message (id_message),
+		KEY id_syndic (id_syndic),
 		KEY statut (statut, date_heure))";
 	$result = spip_query($query);
 
@@ -259,7 +260,7 @@ function creer_base() {
 		maj TIMESTAMP,
 		PRIMARY KEY (id_article))";
 	$result = spip_query($query);
-	
+
 	$query = "CREATE TABLE spip_signatures (
 		id_signature bigint(21) DEFAULT '0' NOT NULL auto_increment,
 		id_article bigint(21) DEFAULT '0' NOT NULL,
@@ -1207,6 +1208,11 @@ function maj_base() {
 		creer_liste_indexation();
 		maj_version (1.600);
 	}
+
+	if ($version_installee < 1.601) {
+		spip_query("ALTER TABLE spip_forum ADD INDEX id_syndic (id_syndic)");
+		maj_version (1.601);
+	}
 }
 
 ?>
diff --git a/ecrire/inc_version.php3 b/ecrire/inc_version.php3
index c29b49a717f1e6eedcfe1162025b79d7c7e8f90c..6dbd89026bd93bb8313c7534d1ac9cd0b4a52d7d 100644
--- a/ecrire/inc_version.php3
+++ b/ecrire/inc_version.php3
@@ -144,7 +144,7 @@ if ($flag_ecrire) {
 // (utilise pour les modifs de la base de donnees)
 
 // version de la base
-$spip_version = 1.600;
+$spip_version = 1.601;
 
 // version de spip
 $spip_version_affichee = "1.6b6 CVS";
diff --git a/ecrire/optimiser.php3 b/ecrire/optimiser.php3
index c03f938220f86832cc46410262a0e074a83e253e..08aeee50ab776f862e186d4e50a4f9e3a638d383 100644
--- a/ecrire/optimiser.php3
+++ b/ecrire/optimiser.php3
@@ -30,6 +30,8 @@ function optimiser_base() {
 		spip_query($query);
 		$query = "DELETE FROM spip_auteurs_rubriques WHERE id_rubrique NOT IN ($rubriques)";
 		spip_query($query);
+		$query = "DELETE FROM spip_mots_rubriques WHERE id_rubrique NOT IN ($rubriques)";
+		spip_query($query);
 	}
 
 
@@ -68,6 +70,8 @@ function optimiser_base() {
 	if ($breves) {
 		$breves = join(",", $breves);
 
+		$query = "DELETE FROM spip_mots_breves WHERE id_breve NOT IN ($breves)";
+		spip_query($query);
 		$query = "DELETE FROM spip_forum WHERE id_breve NOT IN (0,$breves)";
 		spip_query($query);
 	}
@@ -77,7 +81,6 @@ function optimiser_base() {
 	// Sites
 	//
 
-
 	$query = "DELETE FROM spip_syndic WHERE maj < $mydate AND statut = 'refuse'";
 	spip_query($query);
 
@@ -90,6 +93,10 @@ function optimiser_base() {
 
 		$query = "DELETE FROM spip_syndic_articles WHERE id_syndic NOT IN (0,$syndic)";
 		spip_query($query);
+		$query = "DELETE FROM spip_mots_syndic WHERE id_syndic NOT IN ($syndic)";
+		spip_query($query);
+		$query = "DELETE FROM spip_forum WHERE id_syndic NOT IN (0,$syndic)";
+		spip_query($query);
 	}
 
 
@@ -118,7 +125,7 @@ function optimiser_base() {
 		$id_auteur = $row['id_auteur'];
 		$nom = $row['nom'];
 		$email = $row['email'];
-	
+
 		$query2 = "SELECT * FROM spip_auteurs_articles WHERE id_auteur=$id_auteur";
 		$result2 = spip_query($query2);
 		if (!spip_num_rows($result2)) {
@@ -127,80 +134,93 @@ function optimiser_base() {
 			spip_log ("suppression auteur $id_auteur ($nom, $email)");
 		}
 	}
-	
-	
-	//
-	// Forums
-	//
-	
-	$query = "SELECT id_forum FROM spip_forum";
-	$result = spip_query($query);
-	while ($row = spip_fetch_array($result)) $forums[] = $row[0];
-	
-	if ($forums) {
-		$forums = join(",", $forums);
-	
-		$query = "DELETE FROM spip_forum WHERE id_parent NOT IN (0,$forums)";
-		spip_query($query);
 
-		spip_query("DELETE FROM spip_forum WHERE statut='redac' AND  date_heure<DATE_SUB(NOW(),INTERVAL 1 DAY)");
 
-	}
-	
-	
-	
-	
 	//
-	// Messages
+	// Messages prives
 	//
-	
+
 	$query = "SELECT m.id_message FROM spip_messages AS m, spip_auteurs_messages AS lien ".
 		"WHERE m.id_message = lien.id_message GROUP BY m.id_message";
 	$result = spip_query($query);
 	while ($row = spip_fetch_array($result)) $messages[] = $row['id_message'];
-	
+
 	$query = "SELECT id_message FROM spip_messages ".
 		"WHERE type ='affich'";
 	$result = spip_query($query);
 	while ($row = spip_fetch_array($result)) $messages[] = $row['id_message'];
-	
+
 	if ($messages) {
 		$messages = join(",", $messages);
-	
+
 		$query = "DELETE FROM spip_messages WHERE id_message NOT IN ($messages)";
 		spip_query($query);
 		$query = "DELETE FROM spip_forum WHERE id_message NOT IN (0,$messages)";
 		spip_query($query);
 	}
-	
-	
+
+
 	//
 	// Mots-cles
 	//
-	
+
 	$query = "DELETE FROM spip_mots WHERE titre='' AND maj < $mydate";
 	$result = spip_query($query);
-	
+
 	$query = "SELECT id_mot FROM spip_mots";
 	$result = spip_query($query);
 	while ($row = spip_fetch_array($result)) $mots[] = $row['id_mot'];
-	
+
 	if ($mots) {
 		$mots = join(",", $mots);
-	
+
 		$query = "DELETE FROM spip_mots_articles WHERE id_mot NOT IN ($mots)";
 		spip_query($query);
+		$query = "DELETE FROM spip_mots_breves WHERE id_mot NOT IN ($mots)";
+		spip_query($query);
+		$query = "DELETE FROM spip_mots_forum WHERE id_mot NOT IN ($mots)";
+		spip_query($query);
+		$query = "DELETE FROM spip_mots_rubriques WHERE id_mot NOT IN ($mots)";
+		spip_query($query);
+		$query = "DELETE FROM spip_mots_syndic WHERE id_mot NOT IN ($mots)";
+		spip_query($query);
 	}
-	
+
 	//
-	// MySQL
+	// Forums
 	//
-	
-	$query = "OPTIMIZE TABLE spip_meta, "
-		. "spip_articles, spip_rubriques, spip_breves, spip_auteurs, spip_auteurs_articles, spip_forum, spip_forum_cache, spip_mots, spip_mots_articles, "
-		. "spip_index_dico, spip_index_articles, spip_index_rubriques, spip_index_breves, spip_index_auteurs, spip_index_mots, spip_index_syndic";
+
+	$query = "DELETE FROM spip_forum WHERE statut='redac' AND maj < $mydate";
 	spip_query($query);
-	
+
+	$query = "SELECT id_forum FROM spip_forum";
+	$result = spip_query($query);
+	while ($row = spip_fetch_array($result)) $forums[] = $row[0];
+
+	if ($forums) {
+		$forums = join(",", $forums);
+
+		$query = "DELETE FROM spip_forum WHERE id_parent NOT IN (0,$forums)";
+		spip_query($query);
+		$query = "DELETE FROM spip_mots_forum WHERE id_forum NOT IN ($forums)";
+		spip_query($query);
+	}
+
+
+	//
+	// MySQL
+	//
+
+	$query = "SHOW TABLES LIKE '".$GLOBALS['table_prefix']."_%'";
+	$result = spip_query($query);
+	while ($row = spip_fetch_array($result)) $tables[] = $row[0];
+
+	if ($tables) {
+		$tables = join(",", $tables);
+		$query = "OPTIMIZE TABLE ".$tables;
+		spip_query($query);
+	}
+
 	spip_log("optimisation ok");
 }