On Nov 26, 2007 11:09 AM, Vinicius <[EMAIL PROTECTED]> wrote:
> com estas funcoes eu consigo saber o tamanho total da tabela ou de um
> indice especifico,, qria uma funcao que eu colocasse o nome da tabela e
> soubesse o total dos indices desta tabela. Para eu saber separado o
> tamanho que a tabela esta ocupando e o tamanho que os indices desta
> tabela estao ocupando.

create or replace function
pg_hmmm_agora_eu_sei_qual_o_tamanho_dos_indices(IN p_table text, OUT
size TEXT)
language 'plpgsql'
as
$qual_o_tamanho_dos_indices$
declare
sizeof_index integer := 0;
idx pg_indexes%rowtype;
begin
for idx in select *
             from pg_indexes
            where tablename = p_table
loop
  sizeof_index := sizeof_index + pg_relation_size(idx.indexname);
end loop;
size := pg_size_pretty(sizeof_index);
end;
$qual_o_tamanho_dos_indices$

-Leo
-- 
Leonardo Cezar
PgConBrasil: dias 7-8 dezembro 2007
http://pgcon.postgresql.org.br
_______________________________________________
pgbr-geral mailing list
pgbr-geral@listas.postgresql.org.br
https://listas.postgresql.org.br/cgi-bin/mailman/listinfo/pgbr-geral

Responder a