Optimize all tables

Submitted by:Pitter Alderson

Date added:23 October, 2012

Category:MySQL

MySQL code example to optimize all tables of database

Tags: optimize table

Code Snippet:

<?php

dbConnect(); // Database connection

$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());
}
}

?>
 
 

Comments