diff --git a/datamodels/2.x/combodo-db-tools/src/Service/DBToolsUtils.php b/datamodels/2.x/combodo-db-tools/src/Service/DBToolsUtils.php index 5932c1a00..d91002eb8 100644 --- a/datamodels/2.x/combodo-db-tools/src/Service/DBToolsUtils.php +++ b/datamodels/2.x/combodo-db-tools/src/Service/DBToolsUtils.php @@ -14,6 +14,22 @@ use DBObjectSet; class DBToolsUtils { + private static bool $bAnalyzed = false; + + private final static function AnalyzeTables() + { + if (self::$bAnalyzed) { + return; + } + + $oResult = CMDBSource::Query('SHOW TABLES;'); + while ($aRow = $oResult->fetch_array()) { + $sTable = $aRow['0']; + CMDBSource::Query("ANALYZE TABLE `$sTable`; "); + } + self::$bAnalyzed = true; + } + /** * @return int * @throws \CoreException @@ -22,6 +38,7 @@ class DBToolsUtils */ public final static function GetDatabaseSize() { + self::AnalyzeTables(); $sSchema = CMDBSource::DBName(); $sReq = <<