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 1kNcRh-0001QB-3K for pgsql-general@arkaria.postgresql.org; Wed, 30 Sep 2020 13:47:01 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kNcRf-0006er-V6 for pgsql-general@arkaria.postgresql.org; Wed, 30 Sep 2020 13:46:59 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kNcRf-0006ei-NM for pgsql-general@lists.postgresql.org; Wed, 30 Sep 2020 13:46:59 +0000 Received: from gandalf.net-wizard.org ([2a01:4f8:172:2a5c::5]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kNcRY-0002bd-LG for pgsql-general@lists.postgresql.org; Wed, 30 Sep 2020 13:46:58 +0000 Received: from localhost (localhost [127.0.0.1]) by mail.net-wizard.org (Postfix) with ESMTP id 921DD82905; Wed, 30 Sep 2020 15:46:46 +0200 (CEST) X-Virus-Scanned: Gentoo amavisd-new at aragorn Received: from aragorn.net-wizard.org ([127.0.0.1]) by localhost (aragorn.net-wizard.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id v0tuD243vhos; Wed, 30 Sep 2020 15:46:39 +0200 (CEST) Received: from webmail.net-wizard.org (localhost [IPv6:::1]) by gandalf.net-wizard.org (Postfix) with ESMTP id 2C9B082903; Wed, 30 Sep 2020 15:46:39 +0200 (CEST) MIME-Version: 1.0 Date: Wed, 30 Sep 2020 15:46:39 +0200 From: Charles Clavadetscher To: luis.roberto@siscobra.com.br Cc: pgsql-general Subject: Re: Table sizes In-Reply-To: <78366091.53791693.1601467902283.JavaMail.zimbra@siscobra.com.br> References: <78366091.53791693.1601467902283.JavaMail.zimbra@siscobra.com.br> User-Agent: Roundcube Webmail/1.4.8 Message-ID: <899489bcefe7f21b9db422b1ca797e15@swisspug.org> X-Sender: clavadetscher@swisspug.org Organization: Swiss PostgreSQL Users Group Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Hello On 2020-09-30 14:11, luis.roberto@siscobra.com.br wrote: > Hi! > > I'm trying to use this query to get table sizes, however I'm getting a > strange error: > > select tablename,pg_relation_size(tablename::text) > from pg_tables; > > In PG 13: > > SQL Error [42P01]: ERROR: relation "sql_implementation_info" does not > exist > > In PG 12: > > SQL Error [42P01]: ERROR: relation "sql_parts" does not exist Try like this: select schemaname, tablename, pg_relation_size((schemaname || '.' || '"' || tablename || '"')::regclass) from pg_tables; You need to schema qualify the tables. Additionally, if you happen to have table names that have a mix of capital and non capital letters or contain other characters that might be problematic, you need to enclose the table name in double quotes. Regards Charles -- Charles Clavadetscher Swiss PostgreSQL Users Group Treasurer Spitzackerstrasse 9 CH - 8057 Zürich http://www.swisspug.org +---------------------------+ | ____ ______ ___ | | / )/ \/ \ | | ( / __ _\ ) | | \ (/ o) ( o) ) | | \_ (_ ) \ ) _/ | | \ /\_/ \)/ | | \/ | | _| | | | \|_/ | | | | Swiss PostgreSQL | | Users Group | | | +---------------------------+