Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bnRVH-0005qu-Di for pgsql-admin@arkaria.postgresql.org; Fri, 23 Sep 2016 14:31:03 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1bnRVH-0005gu-0T for pgsql-admin@arkaria.postgresql.org; Fri, 23 Sep 2016 14:31:03 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1bnRVG-0005eo-5W for pgsql-admin@postgresql.org; Fri, 23 Sep 2016 14:31:02 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1bnRVD-0008SD-8l for pgsql-admin@postgresql.org; Fri, 23 Sep 2016 14:31:00 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id u8NEUqKP013515; Fri, 23 Sep 2016 10:30:53 -0400 From: Tom Lane To: Artem Tomyuk cc: depesz@depesz.com, pgsql-admin@postgresql.org Subject: Re: Finding the size of your biggest relations In-reply-to: References: <20160923132122.jcpbobqzf3x4emda@depesz.com> Comments: In-reply-to Artem Tomyuk message dated "Fri, 23 Sep 2016 16:31:39 +0300" Date: Fri, 23 Sep 2016 10:30:52 -0400 Message-ID: <13514.1474641052@sss.pgh.pa.us> X-Pg-Spam-Score: -5.0 (-----) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-admin Precedence: bulk Sender: pgsql-admin-owner@postgresql.org Artem Tomyuk writes: > Sorry, > this query > SELECT nspname || '.' || relname AS "relation", > pg_size_pretty(pg_total_relation_size(C.oid)) AS "total_size" > FROM pg_class C > LEFT JOIN pg_namespace N ON (N.oid = C.relnamespace) > WHERE nspname NOT IN ('pg_catalog', 'information_schema') > AND C.relkind <> 'i' > AND nspname !~ '^pg_toast' > ORDER BY pg_total_relation_size(C.oid) DESC > LIMIT 20; I think what's happening is that your ORDER BY is sorting nulls first. So what's coming out at the top is temp relations that were dropped between the time of the statement snapshot and the time that pg_total_relation_size looked at them. Try ORDER BY ... DESC NULLS LAST. regards, tom lane -- Sent via pgsql-admin mailing list (pgsql-admin@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-admin