Re: Table sizes

Поиск
Список
Период
Сортировка
От Charles Clavadetscher
Тема Re: Table sizes
Дата
Msg-id 899489bcefe7f21b9db422b1ca797e15@swisspug.org
обсуждение исходный текст
Ответ на Table sizes  (luis.roberto@siscobra.com.br)
Ответы Re: Table sizes  (luis.roberto@siscobra.com.br)
Список pgsql-general
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         |
|                           |
+---------------------------+



В списке pgsql-general по дате отправления:

Предыдущее
От: "Ireneusz Pluta/wp.pl"
Дата:
Сообщение: Re: Table sizes
Следующее
От: luis.roberto@siscobra.com.br
Дата:
Сообщение: Re: Table sizes