add tables optimization to the cron/cleaner task

This commit is contained in:
ghost 2023-05-14 02:39:32 +03:00
parent 134b70e130
commit 50c9066f62
2 changed files with 19 additions and 1 deletions

View File

@ -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);

View File

@ -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`');
}
} }