summaryrefslogtreecommitdiff
path: root/app/Models/DatabaseDAOPGSQL.php
diff options
context:
space:
mode:
authorGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2019-10-06 22:17:28 +0200
committerGravatar GitHub <noreply@github.com> 2019-10-06 22:17:28 +0200
commit3b65f2e5867b3da176be9e976267633eeccf6184 (patch)
tree319ee2a9b8e3b57750fc8e8a4bab9250447aa745 /app/Models/DatabaseDAOPGSQL.php
parentbe4c942cb3bd2b41dc2e01eb437dfd4f2f73ab4a (diff)
Fix PostgreSQL and SQLite DB size estimation (#2562)
Diffstat (limited to 'app/Models/DatabaseDAOPGSQL.php')
-rw-r--r--app/Models/DatabaseDAOPGSQL.php23
1 files changed, 17 insertions, 6 deletions
diff --git a/app/Models/DatabaseDAOPGSQL.php b/app/Models/DatabaseDAOPGSQL.php
index 60aceacc2..1a6b3599e 100644
--- a/app/Models/DatabaseDAOPGSQL.php
+++ b/app/Models/DatabaseDAOPGSQL.php
@@ -49,12 +49,23 @@ class FreshRSS_DatabaseDAOPGSQL extends FreshRSS_DatabaseDAOSQLite {
);
}
- public function size($all = true) {
- $db = FreshRSS_Context::$system_conf->db;
- $sql = 'SELECT pg_size_pretty(pg_database_size(?))';
- $values = array($db['base']);
- $stm = $this->pdo->prepare($sql);
- $stm->execute($values);
+ public function size($all = false) {
+ if ($all) {
+ $db = FreshRSS_Context::$system_conf->db;
+ $sql = 'SELECT pg_database_size(:base)';
+ $stm = $this->pdo->prepare($sql);
+ $stm->bindParam(':base', $db['base']);
+ $stm->execute();
+ } else {
+ $sql = "SELECT "
+ . "pg_total_relation_size('{$this->pdo->prefix()}category') + "
+ . "pg_total_relation_size('{$this->pdo->prefix()}feed') + "
+ . "pg_total_relation_size('{$this->pdo->prefix()}entry') + "
+ . "pg_total_relation_size('{$this->pdo->prefix()}entrytmp') + "
+ . "pg_total_relation_size('{$this->pdo->prefix()}tag') + "
+ . "pg_total_relation_size('{$this->pdo->prefix()}entrytag')";
+ $stm = $this->pdo->query($sql);
+ }
$res = $stm->fetchAll(PDO::FETCH_COLUMN, 0);
return $res[0];
}