From luis.roberto@siscobra.com.br Wed Sep 30 12:11:42 2020 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 1kNaxe-0006Sc-A1 for pgsql-general@arkaria.postgresql.org; Wed, 30 Sep 2020 12:11:54 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kNaxc-0005bY-N4 for pgsql-general@arkaria.postgresql.org; Wed, 30 Sep 2020 12:11:52 +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 1kNaxc-0005bR-F4 for pgsql-general@lists.postgresql.org; Wed, 30 Sep 2020 12:11:52 +0000 Received: from mxh01aws49.mxout.inova.com.br ([34.198.242.49] 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 1kNaxW-0005RS-GX for pgsql-general@lists.postgresql.org; Wed, 30 Sep 2020 12:11:52 +0000 Received: from ip-10-0-4-78.ec2.internal (localhost [127.0.0.1]) by mxhero01.a.inova.com.br (Postfix) with ESMTP id 63FAF1CA522 for ; Wed, 30 Sep 2020 12:11:43 +0000 (UTC) Received: from corpmoutpolicyd01.a.inova.com.br (puppetmaster.a.inova.com.br [10.0.1.88]) by mxhero01.a.inova.com.br (Postfix) with ESMTP for ; Wed, 30 Sep 2020 12:11:43 +0000 (UTC) Received: from corpmoutpolicyd01.a.inova.com.br (localhost [127.0.0.1]) by corpmoutpolicyd01.a.inova.com.br (Postfix) with ESMTP id 5B5DE2209D1 for ; Wed, 30 Sep 2020 09:11:42 -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 55F8EBD2A1 for ; Wed, 30 Sep 2020 09:11:42 -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 for ; Wed, 30 Sep 2020 09:11:42 -0300 (-03) Date: Wed, 30 Sep 2020 09:11:42 -0300 (BRT) From: luis.roberto@siscobra.com.br To: pgsql-general Message-ID: <78366091.53791693.1601467902283.JavaMail.zimbra@siscobra.com.br> Subject: Table sizes MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="=_39f58a2e-70a2-455f-a9e8-9edcc03d0e2b" X-Originating-IP: [10.0.4.158] X-Mailer: Zimbra 8.8.15_GA_3955 (ZimbraWebClient - GC85 (Win)/8.8.15_GA_3953) Thread-Index: qxM2BntkSK3JgDtXE3HfOk98XY4JKw== Thread-Topic: Table sizes x-mxHero-Origin-Ip: /127.0.0.1:50628 X-mxHero-AttachmentBlock: rule=48;result=false List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --=_39f58a2e-70a2-455f-a9e8-9edcc03d0e2b Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit 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 --=_39f58a2e-70a2-455f-a9e8-9edcc03d0e2b Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable
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_table= s;

In PG 13:<= br data-mce-bogus=3D"1">

SQL Error [42P0= 1]: ERROR: relation "sql_implementation_info" does not exist

= In PG 12:

SQL Error [42P01]: ERROR: relation "sql_parts" does not exist

--=_39f58a2e-70a2-455f-a9e8-9edcc03d0e2b-- From ipluta@wp.pl Wed Sep 30 13:41:38 2020 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 1kNcMg-0001EZ-AL for pgsql-general@arkaria.postgresql.org; Wed, 30 Sep 2020 13:41:51 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kNcMe-00027v-VI for pgsql-general@arkaria.postgresql.org; Wed, 30 Sep 2020 13:41:48 +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 1kNcMe-00027n-JI for pgsql-general@lists.postgresql.org; Wed, 30 Sep 2020 13:41:48 +0000 Received: from mx3.wp.pl ([212.77.101.9]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kNcMb-00067W-L4 for pgsql-general@lists.postgresql.org; Wed, 30 Sep 2020 13:41:48 +0000 Received: (wp-smtpd smtp.wp.pl 23861 invoked from network); 30 Sep 2020 15:41:43 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wp.pl; s=1024a; t=1601473303; bh=RZDd6hHIKfvt7D3JEeuroP7NhKdtRF6+wjXZV2PRe5A=; h=Subject:To:From; b=Jmc+z8fZ15OBsVnpKbNnpiDQkbHQnnAX5c7eRRXLohAkJBG53o2SATB5aD0Of5E4d Xm9gDhl1jOvK94t8bkWEV92L1SlPYyC+I4EZVLPnacivRkvQTfsuv4mzOCMiPjz8Dg vTdQRpH5+GWAezJfZ+h3ZJKYRS3HSIpifBEZqKKc= Received: from 78-11-36-98.cmr.net.pl (HELO [192.168.1.226]) (ipluta@wp.pl@[78.11.36.98]) (envelope-sender ) by smtp.wp.pl (WP-SMTPD) with ECDHE-RSA-AES256-GCM-SHA384 encrypted SMTP for ; 30 Sep 2020 15:41:43 +0200 Subject: Re: Table sizes To: luis.roberto@siscobra.com.br, pgsql-general References: <78366091.53791693.1601467902283.JavaMail.zimbra@siscobra.com.br> From: "Ireneusz Pluta/wp.pl" Message-ID: Date: Wed, 30 Sep 2020 15:41:38 +0200 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.12.0 MIME-Version: 1.0 In-Reply-To: <78366091.53791693.1601467902283.JavaMail.zimbra@siscobra.com.br> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: pl X-WP-MailID: 19117211b1293efc200e5c274f56da8e X-WP-AV: skaner antywirusowy Poczty Wirtualnej Polski X-WP-SPAM: NO 0000009 [IDPU] List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk W dniu 2020-09-30 o 14:11, luis.roberto@siscobra.com.br pisze: > 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 > You need to use full tablenames, using schemaname of pg_tables too. From clavadetscher@swisspug.org Wed Sep 30 13:46:39 2020 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 | | | +---------------------------+ From luis.roberto@siscobra.com.br Wed Sep 30 13:54:32 2020 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 1kNcZJ-0001gv-I3 for pgsql-general@arkaria.postgresql.org; Wed, 30 Sep 2020 13:54:53 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kNcZH-0003JB-Mu for pgsql-general@arkaria.postgresql.org; Wed, 30 Sep 2020 13:54:51 +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 1kNcZH-0003J4-F6 for pgsql-general@lists.postgresql.org; Wed, 30 Sep 2020 13:54:51 +0000 Received: from mxh01aws49.mxout.inova.com.br ([34.198.242.49] 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 1kNcZ6-0006Dw-Er for pgsql-general@lists.postgresql.org; Wed, 30 Sep 2020 13:54:51 +0000 Received: from ip-10-0-4-78.ec2.internal (localhost [127.0.0.1]) by mxhero01.a.inova.com.br (Postfix) with ESMTP id 80EF01CA72A for ; Wed, 30 Sep 2020 13:54:37 +0000 (UTC) Received: from corpmoutpolicyd01.a.inova.com.br (puppetmaster.a.inova.com.br [10.0.1.88]) by mxhero01.a.inova.com.br (Postfix) with ESMTP; Wed, 30 Sep 2020 13:54:37 +0000 (UTC) Received: from corpmoutpolicyd01.a.inova.com.br (localhost [127.0.0.1]) by corpmoutpolicyd01.a.inova.com.br (Postfix) with ESMTP id 70DB6220C03; Wed, 30 Sep 2020 10:54:34 -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 1778ABA4D5; Wed, 30 Sep 2020 10:54:33 -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; Wed, 30 Sep 2020 10:54:33 -0300 (-03) Date: Wed, 30 Sep 2020 10:54:32 -0300 (BRT) From: luis.roberto@siscobra.com.br To: Charles Clavadetscher Cc: pgsql-general Message-ID: <56108176.54473966.1601474072988.JavaMail.zimbra@siscobra.com.br> In-Reply-To: <899489bcefe7f21b9db422b1ca797e15@swisspug.org> References: <78366091.53791693.1601467902283.JavaMail.zimbra@siscobra.com.br> <899489bcefe7f21b9db422b1ca797e15@swisspug.org> Subject: Re: Table sizes MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="=_f7b6ca01-1024-4380-aa2e-1e702777731a" X-Originating-IP: [10.0.1.247] X-Mailer: Zimbra 8.8.15_GA_3955 (ZimbraWebClient - GC85 (Win)/8.8.15_GA_3953) Thread-Topic: Table sizes Thread-Index: R7+1aPrSSkyrx3myQOoQesdz6Gvl7Q== x-mxHero-Origin-Ip: /127.0.0.1:51422 X-mxHero-AttachmentBlock: rule=48;result=false List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --=_f7b6ca01-1024-4380-aa2e-1e702777731a Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable De: "Charles Clavadetscher" =20 Para: "luis.roberto" =20 Cc: "pgsql-general" =20 Enviadas: Quarta-feira, 30 de setembro de 2020 10:46:39=20 Assunto: Re: Table sizes=20 Hello=20 On 2020-09-30 14:11, luis.roberto@siscobra.com.br wrote:=20 > Hi!=20 >=20 > I'm trying to use this query to get table sizes, however I'm getting a=20 > strange error:=20 >=20 > select tablename,pg_relation_size(tablename::text)=20 > from pg_tables;=20 >=20 > In PG 13:=20 >=20 > SQL Error [42P01]: ERROR: relation "sql_implementation_info" does not=20 > exist=20 >=20 > In PG 12:=20 >=20 > SQL Error [42P01]: ERROR: relation "sql_parts" does not exist=20 Try like this:=20 select schemaname,=20 tablename,=20 pg_relation_size((schemaname || '.' || '"' || tablename ||=20 '"')::regclass)=20 from pg_tables;=20 You need to schema qualify the tables. Additionally, if you happen to=20 have table names that have a mix of capital and non capital letters or=20 contain other characters that might be problematic, you need to enclose=20 the table name in double quotes.=20 Regards=20 Charles=20 --=20 Charles Clavadetscher=20 Swiss PostgreSQL Users Group=20 Treasurer=20 Spitzackerstrasse 9=20 CH - 8057 Z=C3=BCrich=20 http://www.swisspug.org=20 +---------------------------+=20 | ____ ______ ___ |=20 | / )/ \/ \ |=20 | ( / __ _\ ) |=20 | \ (/ o) ( o) ) |=20 | \_ (_ ) \ ) _/ |=20 | \ /\_/ \)/ |=20 | \/ |=20 | _| | |=20 | \|_/ |=20 | |=20 | Swiss PostgreSQL |=20 | Users Group |=20 | |=20 +---------------------------+=20 Thanks, this worked.=20 I wonder though, why calling pg_relation_size('users') work (I don't need t= o specify the schema).=20 --=_f7b6ca01-1024-4380-aa2e-1e702777731a Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable
De: "Charles Clavadetscher" <clavadetscher@swisspug.org&g= t;
Para: "luis.roberto" <luis.roberto@siscobra.com.br>
<= b>Cc: "pgsql-general" <pgsql-general@lists.postgresql.org>
= Enviadas: Quarta-feira, 30 de setembro de 2020 10:46:39
Assunto: = Re: Table sizes

Hello

On 2020-09-30 14:11, luis.roberto@siscobra.com.br wrote:=
> Hi!
>
> I'm trying to use this query to get table siz= es, however I'm getting a
> strange error:
>
> select ta= blename,pg_relation_size(tablename::text)
>   from pg_tables;>
> In PG 13:
>
> SQL Error [42P01]: ERROR: relatio= n "sql_implementation_info" does not
> exist
>
> In PG 1= 2:
>
> SQL Error [42P01]: ERROR: relation "sql_parts" does not= exist

Try like this:

select schemaname,
   &nbs= p;    tablename,
        pg_relation_= size((schemaname || '.' || '"' || tablename ||
'"')::regclass)
from = pg_tables;

You need to schema qualify the tables. Additionally, if y= ou happen to
have table names that have a mix of capital and non capita= l letters or
contain other characters that might be problematic, you ne= ed to enclose
the table name in double quotes.

Regards
Charle= s

--
Charles Clavadetscher
Swiss PostgreSQL Users Group
Tr= easurer
Spitzackerstrasse 9
CH - 8057 Z=C3=BCrich

http://www.s= wisspug.org

+---------------------------+
|     ____ &n= bsp;______  ___     |
|    /    )/ &n= bsp;    \/   \    |
|   (     / = __    _\    )   |
|    \    = ;(/ o)  ( o)   )   |
|     \_  (_  ) =   \ ) _/    |
|       \  /\_/   =  \)/      |
|        \/ <//| =  |\\>      |
|          =   _|  |         |
|       =       \|_/          |
|   &= nbsp;                    =   |
|     Swiss PostgreSQL      |
| &n= bsp;     Users Group         |
|   &n= bsp;                     =   |
+---------------------------+


Than= ks, this worked.

I wonder tho= ugh, why calling pg_relation_size('users') work (I don't need to specify th= e schema).
--=_f7b6ca01-1024-4380-aa2e-1e702777731a-- From adrian.klaver@aklaver.com Wed Sep 30 13:59:03 2020 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 1kNcdi-0001qg-Ve for pgsql-general@arkaria.postgresql.org; Wed, 30 Sep 2020 13:59:27 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kNcdh-0007e3-2O for pgsql-general@arkaria.postgresql.org; Wed, 30 Sep 2020 13:59:25 +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 1kNcdf-0007dw-Gr for pgsql-general@lists.postgresql.org; Wed, 30 Sep 2020 13:59:24 +0000 Received: from [64.147.123.21] (helo=wout5-smtp.messagingengine.com) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kNcdZ-0002ig-2M for pgsql-general@lists.postgresql.org; Wed, 30 Sep 2020 13:59:22 +0000 Received: from compute7.internal (compute7.nyi.internal [10.202.2.47]) by mailout.west.internal (Postfix) with ESMTP id 5B09D10A7; Wed, 30 Sep 2020 09:59:05 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute7.internal (MEProxy); Wed, 30 Sep 2020 09:59:05 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= subject:to:cc:references:from:message-id:date:mime-version :in-reply-to:content-type:content-transfer-encoding; s=fm1; bh=r M9PJ3szNCDFxaIhLYzshvDUU5nkj0hXs9RH2YTRZG8=; b=WtLnR8k/YkR3ojkEH zU4zaMLeY3fzeKTs/jIkzwcgjBCdVtOePzqO1KcCaeLV+8mNzyZpSmYc8T69o2Gu TxW1NJOZs/pZuuOUCtAObGpKJ42hvhQDHkIw0463F5qmuQN+yScpe/OHi1JBcgly c1AmlEeEZoILuqmwakCZrm2GNn+8f5y54mXGMnps9ypT9SSqOaveWaFgKHjB2pIW hEHHqMw6B9oiPQLSnDtC7SkhtLTgocLnAuMRq6VRHYYg0F/5sgJmoGaFzxh9bDVi 05dN2Dws2gmywGPlgRLuOx0rItrBk8vigdvm3l0njFBDH52KqgTZxMamedBRGHsq ddcgA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm3; bh=rM9PJ3szNCDFxaIhLYzshvDUU5nkj0hXs9RH2YTRZ G8=; b=DXtCPIwYZHNt8i7XkOGqL9lgtZPE5fdYLGRSiU95l6wSeNbJ+oL7I5rMD YO3ERP9CtsZXU+M2rrFIapZXQ3fQl+ten042c1fcAqj/6gpdV0BYjo+w44a59BWs v9lHCsCGyfttNx8ZXpZYbvzLQpBHwvGpiPEc/f2BxjU/+jpUn4pVa5wTxh8ohhYs Qp+YqjijIF4UE0cPvjkrLBY27MqsgjwSZ+dg4bTkl/3ZoGShxQ+ta48hQkbyv98U 8UghT9+hzGwy4bdP6c3fOHkp5YLX89MCRxNwAgVOtv5IhOfY2KGTtTIznyy7Z5Ml mqsnS1BzM5Q8O7ePMKIUbphvY88Og== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedujedrfedvgdeijecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefuvfhfhffkffgfgggjtgfgsehtjeertddtfeejnecuhfhrohhmpeetughrihgr nhcumfhlrghvvghruceorggurhhirghnrdhklhgrvhgvrhesrghklhgrvhgvrhdrtghomh eqnecuggftrfgrthhtvghrnhepteejvdetffejuedvleeifeefheeutdfhgfdvhffhhfek vdduveegvdejudefgfevnecukfhppeejhedrudejvddrhedrvdefudenucevlhhushhtvg hrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpegrughrihgrnhdrkhhlrghv vghrsegrkhhlrghvvghrrdgtohhm X-ME-Proxy: Received: from [192.168.1.3] (75-172-5-231.tukw.qwest.net [75.172.5.231]) by mail.messagingengine.com (Postfix) with ESMTPA id D27D33064685; Wed, 30 Sep 2020 09:59:03 -0400 (EDT) Subject: Re: Table sizes To: luis.roberto@siscobra.com.br, Charles Clavadetscher Cc: pgsql-general References: <78366091.53791693.1601467902283.JavaMail.zimbra@siscobra.com.br> <899489bcefe7f21b9db422b1ca797e15@swisspug.org> <56108176.54473966.1601474072988.JavaMail.zimbra@siscobra.com.br> From: Adrian Klaver Message-ID: Date: Wed, 30 Sep 2020 06:59:03 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.12.0 MIME-Version: 1.0 In-Reply-To: <56108176.54473966.1601474072988.JavaMail.zimbra@siscobra.com.br> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Host-Lookup-Failed: Reverse DNS lookup failed for 64.147.123.21 (deferred) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 9/30/20 6:54 AM, luis.roberto@siscobra.com.br wrote: > ------------------------------------------------------------------------ > > Thanks, this worked. > > I wonder though, why calling pg_relation_size('users') work (I don't > need to specify the schema). Because it is in the search_path. In psql do: show search_path; It will show you the schemas Postgres will search for a table name without using a schema qualification. -- Adrian Klaver adrian.klaver@aklaver.com From clavadetscher@swisspug.org Wed Sep 30 14:02:21 2020 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 1kNcgd-00021p-Hk for pgsql-general@arkaria.postgresql.org; Wed, 30 Sep 2020 14:02:27 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kNcgc-0002ud-Fn for pgsql-general@arkaria.postgresql.org; Wed, 30 Sep 2020 14:02:26 +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 1kNcgc-0002uR-7u for pgsql-general@lists.postgresql.org; Wed, 30 Sep 2020 14:02:26 +0000 Received: from gandalf.net-wizard.org ([138.201.143.9]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kNcgZ-0006HE-Fj for pgsql-general@lists.postgresql.org; Wed, 30 Sep 2020 14:02:25 +0000 Received: from localhost (localhost [127.0.0.1]) by mail.net-wizard.org (Postfix) with ESMTP id 488008290A; Wed, 30 Sep 2020 16:02:22 +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 qLxF8zj7Dgtl; Wed, 30 Sep 2020 16:02:22 +0200 (CEST) Received: from webmail.net-wizard.org (localhost [IPv6:::1]) by gandalf.net-wizard.org (Postfix) with ESMTP id EC671828F8; Wed, 30 Sep 2020 16:02:21 +0200 (CEST) MIME-Version: 1.0 Date: Wed, 30 Sep 2020 16:02:21 +0200 From: Charles Clavadetscher To: luis.roberto@siscobra.com.br Cc: pgsql-general Subject: Re: Table sizes In-Reply-To: <56108176.54473966.1601474072988.JavaMail.zimbra@siscobra.com.br> References: <78366091.53791693.1601467902283.JavaMail.zimbra@siscobra.com.br> <899489bcefe7f21b9db422b1ca797e15@swisspug.org> <56108176.54473966.1601474072988.JavaMail.zimbra@siscobra.com.br> User-Agent: Roundcube Webmail/1.4.8 Message-ID: <46ba5e4effbac39b4cabec56d3250db2@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 15:54, luis.roberto@siscobra.com.br wrote: >> De: "Charles Clavadetscher" >> Para: "luis.roberto" >> Cc: "pgsql-general" >> Enviadas: Quarta-feira, 30 de setembro de 2020 10:46:39 >> Assunto: Re: Table sizes >> >> 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 | >> | | >> +---------------------------+ > > ------------------------- > > Thanks, this worked. > > I wonder though, why calling pg_relation_size('users') work (I don't > need to specify the schema). Glad to hear that. The other problem probably depend on your search_path. You can look at it using (in a psql shell): show search_path; Tables that are in your search_path don't need to be schema qualified, those that aren't need it. If you need to, you can change your search_path. set search_path to ...; To change it permanently you can use ALTER ROLE: ALTER ROLE SET search_path=... ; Have a look for more information at https://www.postgresql.org/docs/current/ddl-schemas.html (chapter 5.9.3). Regards Charles