Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lb7n2-0006Hm-Ho for pgsql-general@arkaria.postgresql.org; Mon, 26 Apr 2021 20:25:08 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lb7n1-0002Pn-Fs for pgsql-general@arkaria.postgresql.org; Mon, 26 Apr 2021 20:25:07 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lb7n1-0002Pf-7y for pgsql-general@lists.postgresql.org; Mon, 26 Apr 2021 20:25:07 +0000 Received: from mxh02aws140.mxout.inova.com.br ([34.196.109.140] helo=mxhero01.a.inova.com.br) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lb7mw-0001H7-1F for pgsql-general@lists.postgresql.org; Mon, 26 Apr 2021 20:25:06 +0000 Received: from MXHERO01.A.INOVA.COM.BR (localhost [127.0.0.1]) by mxhero01.a.inova.com.br (Postfix) with ESMTP id 9D5BB1F252E for ; Mon, 26 Apr 2021 20:24:59 +0000 (UTC) Received: from corpmoutpolicyd01.a.inova.com.br (ip-10-0-1-88.ec2.internal [10.0.1.88]) by mxhero02.a.inova.com.br (Postfix) with ESMTP; Mon, 26 Apr 2021 20:24:59 +0000 (UTC) Received: from corpmoutpolicyd01.a.inova.com.br (localhost [127.0.0.1]) by corpmoutpolicyd01.a.inova.com.br (Postfix) with ESMTP id 8B5252207F1; Mon, 26 Apr 2021 17:24:56 -0300 (BRT) Received: from corpmout01.a.inova.com.br (ip-10-0-1-125.ec2.internal [10.0.1.125]) by corpmoutpolicyd01.a.inova.com.br (Postfix) with ESMTP id B041AC36CF; Mon, 26 Apr 2021 17:24:54 -0300 (BRT) Received: from corpmbox02.a.inova.com.br (ip-10-0-4-158.ec2.internal [10.0.4.158]) by corpmout01.a.inova.com.br (Postfix) with ESMTP; Mon, 26 Apr 2021 17:24:54 -0300 (-03) Date: Mon, 26 Apr 2021 17:24:54 -0300 (BRT) From: luis.roberto@siscobra.com.br To: pgsql-general Message-ID: <133123052.3128057.1619468694515.JavaMail.zimbra@siscobra.com.br> Subject: DB size MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Originating-IP: [10.0.1.247] X-Mailer: Zimbra 8.8.15_GA_4018 (ZimbraWebClient - GC90 (Win)/8.8.15_GA_4007) Thread-Index: CQnHcxPEFWjrqyFjdoKfe/V4RSPTBg== Thread-Topic: DB size x-mxHero-Origin-Ip: /10.0.4.78:60320 X-mxHero-AttachmentBlock: rule=48;result=false List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk 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