diff options
| author | 2023-09-14 20:23:56 +0200 | |
|---|---|---|
| committer | 2023-09-14 20:23:56 +0200 | |
| commit | 36173608832653ecc1dadb4bdd30e7573675b224 (patch) | |
| tree | 140cd4b03e0c867b725d9e9685f29546fd840c9e /app/Models/DatabaseDAO.php | |
| parent | bc5666cd27ee1172f89603982a44c143ceae08fd (diff) | |
Fix MariaDB size calculation (#5655)
MariaDB requires an `ANALYZE TABLE` to refresh the size information in the metadata.
At the same time, include `DATA_FREE` in the calculation.
https://mariadb.com/kb/en/information-schema-tables-table/
Diffstat (limited to 'app/Models/DatabaseDAO.php')
| -rw-r--r-- | app/Models/DatabaseDAO.php | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/app/Models/DatabaseDAO.php b/app/Models/DatabaseDAO.php index 416c1fb65..f9d2859e8 100644 --- a/app/Models/DatabaseDAO.php +++ b/app/Models/DatabaseDAO.php @@ -174,10 +174,20 @@ class FreshRSS_DatabaseDAO extends Minz_ModelPdo { public function size(bool $all = false): int { $db = FreshRSS_Context::$system_conf->db; + + // MariaDB does not refresh size information automatically + $sql = <<<'SQL' +ANALYZE TABLE `_category`, `_feed`, `_entry`, `_entrytmp`, `_tag`, `_entrytag` +SQL; + $stm = $this->pdo->query($sql); + if ($stm !== false) { + $stm->fetchAll(); + } + //MySQL: $sql = <<<'SQL' -SELECT SUM(data_length + index_length) -FROM information_schema.TABLES WHERE table_schema=:table_schema +SELECT SUM(DATA_LENGTH + INDEX_LENGTH + DATA_FREE) +FROM information_schema.TABLES WHERE TABLE_SCHEMA=:table_schema SQL; $values = [':table_schema' => $db['base']]; if (!$all) { |
