Il seguente comando permette di controllare, riparare e ottimizzare tutte le tabelle presenti in un database mysql.
mysqlcheck -u USER -pPWD --auto-repair --check --optimize --all-databases
il mysqlcheck è presente nella bin del vostro db mysql
Molto utile potrebbe essere creare uno script php sul vostro sito che viene lanciato periodicamente:
esempio:
<?php
dbConnect()
$alltables = mysql_query("SHOW TABLES");
while ($table = mysql_fetch_assoc($alltables))
{
foreach ($table as $db => $tablename)
{
mysql_query("OPTIMIZE TABLE '".$tablename."'")
or die(mysql_error());
}
}
?>