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 1nH9Ht-0001BW-OC for pgsql-performance@arkaria.postgresql.org; Mon, 07 Feb 2022 19:02:57 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nH9Hs-0002Pw-Iu for pgsql-performance@arkaria.postgresql.org; Mon, 07 Feb 2022 19:02:56 +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 1nH9Hs-0002Pm-9M for pgsql-performance@lists.postgresql.org; Mon, 07 Feb 2022 19:02:56 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nH9Hq-0008Ju-72 for pgsql-performance@lists.postgresql.org; Mon, 07 Feb 2022 19:02:55 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 217J2opG1016662; Mon, 7 Feb 2022 14:02:51 -0500 From: Tom Lane To: Lars Aksel Opsahl cc: Vijaykumar Jain , Pgsql Performance Subject: Re: slow "select count(*) from information_schema.tables;" in some cases In-reply-to: References: Comments: In-reply-to Lars Aksel Opsahl message dated "Mon, 07 Feb 2022 18:55:57 +0000" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1016660.1644260570.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Mon, 07 Feb 2022 14:02:50 -0500 Message-ID: <1016661.1644260570@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Lars Aksel Opsahl writes: >> SELECT relname, pg_size_pretty(pg_relation_size(C.oid)) FROM pg_class C= LEFT JOIN pg_namespace N ON (N.oid =3D C.relnamespace) WHERE nspname =3D = 'pg_catalog' ORDER BY 2 DESC LIMIT 20; can you show the output of this que= ry "ORDER BY 2" is giving you a textual sort of the sizes, which is entirely unhelpful. Try SELECT relname, pg_size_pretty(pg_relation_size(C.oid)) FROM pg_class C LE= FT JOIN pg_namespace N ON (N.oid =3D C.relnamespace) WHERE nspname =3D 'pg= _catalog' ORDER BY pg_relation_size(C.oid) DESC LIMIT 20; regards, tom lane