From 8b42dba8fa265cd6ab95d2fc55e9e962d127bb29 Mon Sep 17 00:00:00 2001 From: Conrad Vermeulen Date: Thu, 4 Oct 2007 09:57:38 +0000 Subject: [PATCH] KTC-239 "CLONE -Performance has become tragically slow (SUP-443)" Added. Implemented a a command line script to do basic mysql optmisation on tables. --- bin/dbmaint.php | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+), 0 deletions(-) create mode 100644 bin/dbmaint.php diff --git a/bin/dbmaint.php b/bin/dbmaint.php new file mode 100644 index 0000000..ed9a2a2 --- /dev/null +++ b/bin/dbmaint.php @@ -0,0 +1,52 @@ + 0) +{ + foreach($argv as $arg) + { + $arg=strtolower($arg); + switch ($arg) + { + case 'check': + case 'repair': + case 'optimize': + $sqlaction="$arg table"; + $action = $arg; + break; + case 'help': + print "Usage: dbmaint.php repair|check|optimize\n"; + exit; + } + } +} + +print '* ' . sprintf(_kt("Action selected: %s"), $action) . "\n\n"; + +$sql = "show tables"; +$tables = DBUtil::getResultArray($sql); +foreach($tables as $table) +{ + $key = array_keys($table); + + $tablename=$table[$key[0]]; + $sql = "$sqlaction $tablename"; + $result = DBUtil::getOneResult($sql); + + if (PEAR::isError($result)) + { + print sprintf(_kt("Attempted: %s"), $sql) . "\n"; + print sprintf(_kt(' *: %s'), $result->getMessage()) . "\n"; + continue; + } + print sprintf(_kt("Running: %s - %s"), $sql, $result['Msg_text']) . "\n"; +} + +print _kt('Done.') . "\n"; + +?> \ No newline at end of file -- libgit2 0.21.4