Browse Source

add tables optimization to the cron/cleaner task

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

4
crontab/cleaner.php

@ -189,8 +189,12 @@ 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();
// Optimize tables
$db->optimize();
} catch(Exception $e) { } 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