Commit 7a74a5d7fbd4913c5614f75262f0697aa8c87df3

Authored by Megan Watson
1 parent b5c2cf63

KTC-239

"CLONE -Performance has become tragically slow (SUP-443)"
Fixed. Added the DB optimise script to the scheduler. Modified the script to log messages instead of printing them. Added a check on the id to the scheduler tasks in the upgrade script.

Committed by: Megan Watson
Reviewed by: Conrad Vermeulen




git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@7779 c91229c3-7414-0410-bfa2-8a42b809f60b
bin/dbmaint.php
... ... @@ -2,51 +2,57 @@
2 2  
3 3 require_once('../config/dmsDefaults.php');
4 4  
5   -print _kt('DB Maintenance') . "...\n\n";
6   -
7 5 $action = 'check';
8 6 $sqlaction = 'check table';
9 7 if ($argc > 0)
10 8 {
11 9 foreach($argv as $arg)
12 10 {
13   - $arg=strtolower($arg);
14   - switch ($arg)
  11 + $action=strtolower($arg);
  12 + switch ($action)
15 13 {
16   - case 'check':
17 14 case 'repair':
  15 + $sqlaction='repair table';
  16 + break;
18 17 case 'optimize':
19   - $sqlaction="$arg table";
20   - $action = $arg;
  18 + $sqlaction='optimize table';
21 19 break;
22 20 case 'help':
23 21 print "Usage: dbmaint.php repair|check|optimize\n";
24 22 exit;
  23 + case 'check':
  24 + default:
  25 + $action = 'check';
  26 + $sqlaction='check table';
  27 + break;
25 28 }
26 29 }
27 30 }
28 31  
29   -print '* ' . sprintf(_kt("Action selected: %s"), $action) . "\n\n";
  32 +$default->log->info("DB Maintenance... \nAction selected: {$action}");
30 33  
31 34 $sql = "show tables";
32 35 $tables = DBUtil::getResultArray($sql);
33   -foreach($tables as $table)
34   -{
35   - $key = array_keys($table);
36   -
37   - $tablename=$table[$key[0]];
38   - $sql = "$sqlaction $tablename";
39   - $result = DBUtil::getOneResult($sql);
40 36  
41   - if (PEAR::isError($result))
42   - {
43   - print sprintf(_kt("Attempted: %s"), $sql) . "\n";
44   - print sprintf(_kt(' *: %s'), $result->getMessage()) . "\n";
45   - continue;
46   - }
47   - print sprintf(_kt("Running: %s - %s"), $sql, $result['Msg_text']) . "\n";
  37 +if(!empty($tables)){
  38 + foreach($tables as $table)
  39 + {
  40 + $key = array_keys($table);
  41 +
  42 + $tablename=$table[$key[0]];
  43 + $sql = "$sqlaction $tablename;";
  44 + $result = DBUtil::getOneResult($sql);
  45 +
  46 + if (PEAR::isError($result))
  47 + {
  48 + $default->log->error('Attempted: '.$sql);
  49 + $default->log->error(' *: '.$result->getMessage());
  50 + continue;
  51 + }
  52 + $default->log->info('Running: '.$sql .' - '. $result['Msg_text']);
  53 + }
48 54 }
49 55  
50   -print _kt('Done.') . "\n";
  56 +$default->log->info('Done.');
51 57  
52 58 ?>
53 59 \ No newline at end of file
... ...
sql/mysql/install/data.sql
No preview for this file type
sql/mysql/upgrade/3.5.2/scheduler_tasks.sql
... ... @@ -2,4 +2,10 @@ ALTER TABLE `scheduler_tasks` ADD `status` ENUM( 'enabled', 'disabled', 'sy
2 2  
3 3 UPDATE `scheduler_tasks` SET `status` = 'system' WHERE `task` = 'Indexing' OR `task` = 'Index Migration' OR `task` = 'Index Optimisation';
4 4  
5   -INSERT INTO `scheduler_tasks` VALUES (4,'Periodic Document Expunge','bin/expungeall.php','',0,'weekly','2007-10-01',NULL,0,'disabled');
6 5 \ No newline at end of file
  6 +select @id:=ifnull(max(id),0)+1 from scheduler_tasks;
  7 +INSERT INTO `scheduler_tasks` VALUES (id,'Periodic Document Expunge','bin/expungeall.php','',0,'weekly','2007-10-01',NULL,0,'disabled');
  8 +
  9 +select @id:=max(id)+1 from scheduler_tasks;
  10 +INSERT INTO `scheduler_tasks` VALUES (id,'Database Maintenance','bin/dbmaint.php','optimize',0,'monthly','2007-10-01',NULL,0,'disabled');
  11 +
  12 +UPDATE zseq_scheduler_tasks set id=@id;
7 13 \ No newline at end of file
... ...