Re: LISTAR TABLAS Y SU TAMAÑO

From: Francisco Olarte <folarte(at)peoplecall(dot)com>
To: Maria Antonieta Ramirez <maramirez(at)ulsaneza(dot)edu(dot)mx>
Cc: FORO POSTGRES <pgsql-es-ayuda(at)postgresql(dot)org>
Subject: Re: LISTAR TABLAS Y SU TAMAÑO
Date: 2017-08-09 15:46:03
Message-ID: CA+bJJbyKYpL27E6wy4Y6V2S8jEKW6qHCY=QMUAbFEU7+tKUmYQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-es-ayuda

Buenas tardes.

2017-07-26 19:37 GMT+02:00 Maria Antonieta Ramirez <maramirez(at)ulsaneza(dot)edu(dot)mx>:
> Quiero listar las tablas de mi esquema y su tamaño, ENCONTRE UNA FORMA PERO
> ES HACIENDO UNA POR UNA Y QUIERO VER SI TIENEN UN QUERY QUE ME PUEDA
> FACILITAR Y REDUCIR EL TIEMPO.

Ya te han dado una respuesta por ahi. Aparte de eso, en general para
este tipo de cosas, que son similares a lo que hace el psql:
>>>
n=> \d+
List of relations
Schema | Name | Type | Owner | Size | Description
--------+-----------------------+-------+-----------+---------+-------------
Contentss deleted...
<<<

Yo te recomendaria intentar simepre buscar un comando similar, poner
ECHO_HIDDEN, que te dice como lo hace el psql y trabajar desde ahi, la
gente que hace el psql ha metido un monton de conocimiento y trucos
dentro:

>>>
n=> \set ECHO_HIDDEN on
n=> \d+
********* QUERY **********
SELECT n.nspname as "Schema",
c.relname as "Name",
CASE c.relkind WHEN 'r' THEN 'table' WHEN 'v' THEN 'view' WHEN 'm'
THEN 'materialized view' WHEN 'i' THEN 'index' WHEN 'S' THEN
'sequence' WHEN 's' THEN 'special' WHEN 'f' THEN 'foreign table' END
as "Type",
pg_catalog.pg_get_userbyid(c.relowner) as "Owner",
pg_catalog.pg_size_pretty(pg_catalog.pg_table_size(c.oid)) as "Size",
pg_catalog.obj_description(c.oid, 'pg_class') as "Description"
FROM pg_catalog.pg_class c
LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace
WHERE c.relkind IN ('r','v','m','S','f','')
AND n.nspname <> 'pg_catalog'
AND n.nspname <> 'information_schema'
AND n.nspname !~ '^pg_toast'
AND pg_catalog.pg_table_is_visible(c.oid)
ORDER BY 1,2;
**************************

List of relations
Schema | Name | Type | Owner | Size | Description
--------+-----------------------+-------+-----------+---------+-------------
<<<<<

Hasta la han formateado bonita ;-)

Francisco Olarte.

In response to

Browse pgsql-es-ayuda by date

  From Date Subject
Next Message FLOR AVILA ELIAS 2017-08-09 17:38:37 POSTGRES TABLA CON OWNER REPLICATOR
Previous Message Daymel Bonne 2017-08-09 14:29:01 Re: LISTAR TABLAS Y SU TAMAÑO