From: luis.roberto@siscobra.com.br
To: pgsql-general <pgsql-general@lists.postgresql.org>
Subject: DB size
Date: Mon, 26 Apr 2021 17:24:54 -0300 (BRT)
Message-ID: <133123052.3128057.1619468694515.JavaMail.zimbra@siscobra.com.br> (raw)
Hi!
I've looked around, but could only find very old answers to this question, and maybe it changed since then...
I'm struggling to identify the cause of the difference in size between the sum of all relations (via pg_total_relation_size) and pg_database_size:
SELECT sum(pg_total_relation_size(relid)),
pg_size_pretty(sum(pg_total_relation_size(relid)))
FROM pg_catalog.pg_stat_all_tables
sum |pg_size_pretty|
------------+--------------+
518549716992|483 GB |
SELECT pg_database_size('mydb'),
pg_size_pretty(pg_database_size('mydb'))
pg_database_size|pg_size_pretty|
----------------+--------------+
869150909087|809 GB |
There are three databases in the cluster, apart from 'mydb' (one of them is the 'postgres' database). These other two size about 8MB each.
We run pg_repack weekly and recently had crashes related to disk running out of space, so my guess is something got 'lost' during repack.
What can I do to recover the wasted space?
Thanks!
Luis R. Weck
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: luis.roberto@siscobra.com.br
Subject: Re: DB size
In-Reply-To: <133123052.3128057.1619468694515.JavaMail.zimbra@siscobra.com.br>
References: <133123052.3128057.1619468694515.JavaMail.zimbra@siscobra.com.br>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox