Browse Source

add tables optimization to the cron/cleaner task

main
ghost 2 years ago
parent
commit
50c9066f62
  1. 6
      crontab/cleaner.php
  2. 14
      library/mysql.php

6
crontab/cleaner.php

@ -189,9 +189,13 @@ try {
$logsCleanerDeleted += $db->deleteLogCleaner(time() - CLEAN_LOG_SECONDS_OFFSET); $logsCleanerDeleted += $db->deleteLogCleaner(time() - CLEAN_LOG_SECONDS_OFFSET);
$logsCrawlerDeleted += $db->deleteLogCrawler(time() - CRAWL_LOG_SECONDS_OFFSET); $logsCrawlerDeleted += $db->deleteLogCrawler(time() - CRAWL_LOG_SECONDS_OFFSET);
// Commit results
$db->commit(); $db->commit();
} catch(Exception $e){ // Optimize tables
$db->optimize();
} catch(Exception $e) {
var_dump($e); var_dump($e);

14
library/mysql.php

@ -629,4 +629,18 @@ class MySQL {
return $query->rowCount(); return $query->rowCount();
} }
public function optimize() {
$this->_db->query('OPTIMIZE TABLE `host`');
$this->_db->query('OPTIMIZE TABLE `hostPage`');
$this->_db->query('OPTIMIZE TABLE `hostPageDescription`');
$this->_db->query('OPTIMIZE TABLE `hostPageSnap`');
$this->_db->query('OPTIMIZE TABLE `hostPageToHostPage`');
$this->_db->query('OPTIMIZE TABLE `logCleaner`');
$this->_db->query('OPTIMIZE TABLE `logCrawler`');
$this->_db->query('OPTIMIZE TABLE `manifest`');
}
} }

Loading…
Cancel
Save