Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gW1W8-0006DH-VK for pgsql-performance@arkaria.postgresql.org; Sun, 09 Dec 2018 16:01:17 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gW1W7-0004Dr-Kj for pgsql-performance@arkaria.postgresql.org; Sun, 09 Dec 2018 16:01:15 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gW1W7-0004Dk-9S for pgsql-performance@lists.postgresql.org; Sun, 09 Dec 2018 16:01:15 +0000 Received: from mail-io1-xd44.google.com ([2607:f8b0:4864:20::d44]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gW1W4-00074a-Cv for pgsql-performance@lists.postgresql.org; Sun, 09 Dec 2018 16:01:14 +0000 Received: by mail-io1-xd44.google.com with SMTP id l14so6905045ioj.5 for ; Sun, 09 Dec 2018 08:01:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=telsasoft-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=puc/ZJNwU5WmF2n3zcNk9yQr7KhH7MRTw/qa30EO6nc=; b=1ufkoJ497gdD/RACVBGTWCjTJCGQVZXru7a2We7mxWL/WH5WWiPBQdza85Z7gOIsa3 ihsUfz11JZ8+cfNFYtE2fekKqa23yOCrLtqhICMdq01Gmll7dfzKyyNV4qpHBT5O5MRM 9nsLWJuBsBuCdZKs4H8mGlj4RgmDy5ue2tMT3UOAaFKVaW8FsW+58kkcHNv+H36R+d/a 6GjulWyPFNUet0y8yISo9YGobMg/KZ0mIB2O/mNpBd72bjZZ/bVF2BKGnf/gbRfzdU1u PCFhW851LcyM9G3nvm4OpvURp5QgSoKAVXESvRFkrZnDITdbXG2QKBGSks3mF+FtBOE8 kWXg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=puc/ZJNwU5WmF2n3zcNk9yQr7KhH7MRTw/qa30EO6nc=; b=i4fTM/MNtTJrNv8sWWDhwEbwUUYMsffxF7J637ydIqS/jdaGZbWYMtcMTlJ6lByiw3 Yz3XmJoYDzgV+upLufbvqbNONeBA8HyhS8oQhQN9j24nDxasHRgzlmEhv/3pl+IjGf8N dqFO53OcTny/RAPqA246FxKjrTfIVtNgNWuvNoiMPRRvte4jUibs8VXnC1nALlAHfJrk 8iQxR6U/AyTv9EkB5SMVx1G5ee2ceAC6gJWtA/ZYJr34YMjF9UQHDOPWZzwrrV8U1M8S WCu2uE9O4ZM67om4FY4L6X8QRgXS4L1D9k3tMZ2p83MEzgaCpOG2JbjP/EwKC5OQriWL E6sA== X-Gm-Message-State: AA+aEWbVNqRuU/YC0WsJutnh5+aZfmnylVEXKwkujHVtY+Q5+mOGM4hg BUgesnvKIbORz6HUWumJ/M5gbQ== X-Google-Smtp-Source: AFSGD/XOm2E16bLFGV6vdySmZRcBs6rqzb/YUi9yfeDfjj2UCMLGNaegUjdrbGxHMnL0Xikynos6gw== X-Received: by 2002:a6b:5101:: with SMTP id f1mr7172591iob.87.1544371270277; Sun, 09 Dec 2018 08:01:10 -0800 (PST) Received: from pryzbyj (charmander.telsasoft.com. [50.244.222.1]) by smtp.gmail.com with ESMTPSA id q9sm3281546ioh.32.2018.12.09.08.01.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 09 Dec 2018 08:01:09 -0800 (PST) Received: by pryzbyj (Postfix, from userid 1000) id EDE79801E71; Sun, 9 Dec 2018 10:01:08 -0600 (CST) Date: Sun, 9 Dec 2018 10:01:08 -0600 From: Justin Pryzby To: Mariel Cherkassky Cc: pgsql-performance@lists.postgresql.org Subject: Re: Database size 1T but unclear why Message-ID: <20181209160108.GB4848@telsasoft.com> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.23 (2014-03-12) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Sun, Dec 09, 2018 at 05:18:55PM +0200, Mariel Cherkassky wrote: > I'm trying to understand why my database consume so much space. I checked > the space it consume on disk : This seems to be essentially the same question you asked last month, so should either continue the existing thread or link to it. I went to the effort to look it up: https://www.postgresql.org/message-id/flat/CA%2Bt6e1mtdVct%2BCn%3Dqs%3Dq%3DLLL_yKSssO6dxiZk%2Bb16xq4ccvWvw%40mail.gmail.com > [root@ base]# du -sh * | sort -n > 1.1T 17312 > 5.2G pgsql_tmp > 6.3M 1 > 6.3M 12865 > 6.4M 12870 > 119G 17313 du -h shouldn't be passed to sort -n. To get useful, sorted output, use du -m. > However, when checking the sizes of my biggest tables (included with > indexes and toasts) : > select a.oid as oid a.relname as table_name,pg_relation_size(a.oid, > 'main')/1024/1024 as main_MB, > pg_relation_size(a.oid, 'fsm')/1024/1024 as fsm_MB, > pg_relation_size(a.oid, 'vm')/1024/1024 as vm_MB, > pg_relation_size(a.oid, 'init')/1024/1024 as init_MB, > pg_table_size(a.oid)/1024/1024 AS relation_size_mb, > pg_indexes_size(a.oid)/1024/1024 as indexes_MB, > pg_total_relation_size(a.oid)/1024/1024 as total_size_MB > from pg_class a where relkind in ('r','t') order by > relation_size_mb desc,total_size_MB desc limit 10; Why condition on relkind ? It's possible an index or materialized view is huge. Other "kind"s may be tiny...but no reason not to check. Why not sort by pg_total_relation_size() ? That would show a bloated index, but I think your current query could miss it, if it wasn't also in the top 10 largest tables. > So is there an option of orphans files in case vacuum full failed ? Andrew answered here: https://www.postgresql.org/message-id/87pnvl2gki.fsf%40news-spur.riddles.org.uk > In addition, what else would you recommend to check to understand why the > database consume so much space ? You can run: du --max=3 -mx ..../base/17312 |sort -nr |head And: find ..../base/17312 -printf '%s %p\n' |sort -nr |head That works for anything, not just postgres. As andrew suggested, you should look for files which have no associated filenode. You should use pg_relation_filenode(pg_class.oid), or maybe pg_filenode_relation(tablespace oid, filenode oid) https://www.postgresql.org/docs/current/functions-admin.html Justin