Respondendo a uma solicitação
Relacionar tabelas pelo tamanho, tenho um sql q funciona bem...
SELECT
esquema, tabela,
pg_size_pretty(pg_relation_size(esq_tab)) AS tamanho,
pg_size_pretty(pg_total_relation_size(esq_tab)) AS tamanho_total
FROM (SELECT tablename AS tabela,
schemaname AS esquema,
schemaname||'.'||tablename AS
esq_tab
FROM pg_catalog.pg_tables
WHERE schemaname NOT
IN ('pg_catalog',
'information_schema', 'pg_toast') ) AS ss
ORDER BY pg_total_relation_size(esq_tab)
DESC;
Silvano de Souza
> From: [email protected]
> Subject: Digest pgbr-geral, volume 28, assunto 2
> To: [email protected]
> Date: Mon, 1 Jun 2009 12:00:04 -0300
>
> Send pgbr-geral mailing list submissions to
> [email protected]
>
> To subscribe or unsubscribe via the World Wide Web, visit
> https://listas.postgresql.org.br/cgi-bin/mailman/listinfo/pgbr-geral
> or, via email, send a message with subject or body 'help' to
> [email protected]
>
> You can reach the person managing the list at
> [email protected]
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of pgbr-geral digest..."
>
>
> Tópicos de Hoje:
>
> 1. Re: listar tabelas pelo tamanho (Leandro Cavalari Soares)
> 2. Res: listar tabelas pelo tamanho (paulo matadr)
> 3. Re: listar tabelas pelo tamanho (Dickson S. Guedes)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Mon, 1 Jun 2009 10:57:48 -0300
> From: Leandro Cavalari Soares <[email protected]>
> Subject: Re: [pgbr-geral] listar tabelas pelo tamanho
> To: Comunidade PostgreSQL Brasileira
> <[email protected]>
> Message-ID:
> <[email protected]>
> Content-Type: text/plain; charset="iso-8859-1"
>
> Tenho duas que são úteis pra minha aplicação onde listo os TOP 10 (índices e
> tabelas), mas são separadas:
>
> - ÍNDICES:
> - SELECT relname AS indice, pg_size_pretty(relpages*8192) as "tamanho"
> FROM pg_class JOIN pg_indexes ON relname = indexname ORDER BY
> relpages DESC
> limit 10;
> - TABELAS:
> - SELECT relname AS tabela, pg_size_pretty(relpages*8192) as "tamanho"
> FROM pg_class JOIN pg_tables ON relname = tablename ORDER BY
> relpages DESC
> limit 10;
>
> A partir delas você pode gerar o que precisa.
>
> Até Mais!
>
> 2009/6/1 paulo matadr <[email protected]>
>
> > Pessoal, alguem tem ai uma query pronta pra listar por tamanho (com indice)
> > as tabelas do banco.
> > agradeço desde ja
> >
> > ------------------------------
> > Veja quais são os assuntos do momento no Yahoo! + Buscados: Top
> > 10<http://br.rd.yahoo.com/mail/taglines/mail/*http://br.maisbuscados.yahoo.com/>-
> > Celebridades<http://br.rd.yahoo.com/mail/taglines/mail/*http://br.maisbuscados.yahoo.com/celebridades/>-
> > Música<http://br.rd.yahoo.com/mail/taglines/mail/*http://br.maisbuscados.yahoo.com/m%C3%BAsica/>-
> > Esportes<http://br.rd.yahoo.com/mail/taglines/mail/*http://br.maisbuscados.yahoo.com/esportes/>
> >
> > _______________________________________________
> > pgbr-geral mailing list
> > [email protected]
> > https://listas.postgresql.org.br/cgi-bin/mailman/listinfo/pgbr-geral
> >
> >
>
>
> --
> Leandro Cavalari Soares
> Analista de Sistemas / DBA
> Veltrac - Tecnologia em Logística
> (43) 2105-5614 / (43) 9922-8095 - Londrina / PR
> -------------- Próxima Parte ----------
> Um anexo em HTML foi limpo...
> URL:
> http://listas.postgresql.org.br/pipermail/pgbr-geral/attachments/20090601/76704f41/attachment-0001.htm
>
>
> ------------------------------
>
> Message: 2
> Date: Mon, 1 Jun 2009 07:12:44 -0700 (PDT)
> From: paulo matadr <[email protected]>
> Subject: [pgbr-geral] Res: listar tabelas pelo tamanho
> To: [email protected], Comunidade PostgreSQL
> Brasileira <[email protected]>
> Message-ID: <[email protected]>
> Content-Type: text/plain; charset="utf-8"
>
> obrigado
> Foi certinho o que eu queria
>
>
>
>
>
> ________________________________
> De: "[email protected]" <[email protected]>
> Para: Comunidade PostgreSQL Brasileira <[email protected]>
> Enviadas: Segunda-feira, 1 de Junho de 2009 10:56:02
> Assunto: Re: [pgbr-geral] listar tabelas pelo tamanho
>
>
> SELECT n.nspname AS schemaname, c.relname AS
> tablename, C.reltuples::int AS Registros,
> pg_size_pretty(pg_relation_size(n.nspname ||?.'||c.relname)) as Tamanho
> FROM
> pg_class c
> LEFT JOIN pg_namespace n ON n.oid = c.relnamespace
> LEFT JOIN
> pg_tablespace t ON t.oid = c.reltablespace
> WHERE c.relkind =
> ?r?::?char?
> ?AND n.nspname = ?acc?
> AND nspname NOT
> IN
> (?dbateste?,'information_schema?,'pg_catalog?,'pg_temp_1',?pg_toast?,'postgres?,'publico?,'public?)
> ORDER
> BY n.nspname
>
> ----- Original Message -----
> From: paulo matadr
> To: pgbr_LISTA
> Sent: Monday, June 01, 2009 10:41
> AM
> Subject: [pgbr-geral] listar tabelas pelo tamanho
>
> Pessoal, alguem tem ai uma query pronta pra listar por tamanho (com indice)
> as tabelas do banco.
> agradeço desde ja
>
> ________________________________
> Veja quais são os assuntos do momento no Yahoo! + Buscados: Top 10 -
> Celebridades - Música - Esportes
> ________________________________
> _______________________________________________
> pgbr-geral mailing list
> [email protected]
> https://listas.postgresql.org.br/cgi-bin/mailman/listinfo/pgbr-geral
>
>
>
> Veja quais são os assuntos do momento no Yahoo! +Buscados
> http://br.maisbuscados.yahoo.com
> -------------- Pr?a Parte ----------
> Um anexo em HTML foi limpo...
> URL:
> http://listas.postgresql.org.br/pipermail/pgbr-geral/attachments/20090601/d5e22c32/attachment-0001.htm
>
>
> ------------------------------
>
> Message: 3
> Date: Mon, 01 Jun 2009 11:39:29 -0300
> From: "Dickson S. Guedes" <[email protected]>
> Subject: Re: [pgbr-geral] listar tabelas pelo tamanho
> To: Comunidade PostgreSQL Brasileira
> <[email protected]>
> Message-ID: <[email protected]>
> Content-Type: text/plain; charset="iso-8859-1"
>
> Em Seg, 2009-06-01 às 06:41 -0700, paulo matadr escreveu:
> > Pessoal, alguem tem ai uma query pronta pra listar por tamanho (com
> > indice) as tabelas do banco.
> > agradeço desde ja
>
> Fazendo um adendo ao que os demais colegas sugeriram vale dar uma olhada
> em:
>
> http://wiki.postgresql.org/wiki/Disk_Usage
>
>
> []s
> --
> Dickson S. Guedes
> mail/xmpp: [email protected] - skype: guediz
> http://guedesoft.net - http://www.postgresql.org.br
> http://www.rnp.br/keyserver/pks/lookup?search=0x8F3E3C06D428D10A
> -------------- Próxima Parte ----------
> Um anexo não texto foi limpo...
> Nome : não disponível
> Tipo : application/pgp-signature
> Tam : 189 bytes
> Descr.: Esta =?ISO-8859-1?Q?=E9?= uma parte de mensagem
> assinada digitalmente
> Url :
> http://listas.postgresql.org.br/pipermail/pgbr-geral/attachments/20090601/e05e3865/attachment-0001.pgp
>
>
> ------------------------------
>
> _______________________________________________
> pgbr-geral mailing list
> [email protected]
> https://listas.postgresql.org.br/cgi-bin/mailman/listinfo/pgbr-geral
>
>
> Fim da Digest pgbr-geral, volume 28, assunto 2
> **********************************************
_______________________________________________
pgbr-geral mailing list
[email protected]
https://listas.postgresql.org.br/cgi-bin/mailman/listinfo/pgbr-geral