Consultas rotineiras

1 – verificar processos PostgreSQL:

ps aux | grep “postgres” | grep-v "grep"
ShellScript

2 – Status conexão de rede:

netstat-ntu | grep "TIME_WAIT" | wc-l
ShellScript

3 – Informações sobre base de dados disponíveis:

SELECT SUM (pg_database_size (OID)) FROM pg_database;
ShellScript

4 – Locks:

SELECT * FROM pg_locks;
SELECT COUNT (*) FROM pg_locks;
ShellScript

Processos ativos:

SELECT COUNT (usename) FROM pg_stat_activity;
ShellScript

6 – Cache utilizado:

SELECT SUM (blks_hit) / SUM (blks_read) FROM pg_stat_database;
ShellScript

7 – Tamanho da base:

postgres=# SELECT pg_database_size('geekdb');
ShellScript

8 – Tamanho real do banco no disco arredondando:

postgres=# SELECT pg_size_pretty(pg_database_size('somedatabase')) As fulldbsize;
ShellScript

9 – Tamanho de uma tabela:

postgres=# SELECT pg_size_pretty(pg_total_relation_size('drupal_cache'));
ShellScript

10 – Tamanho de todas as tabelas:

relname as "Table",
pg_size_pretty(pg_total_relation_size(relid)) As "Size",
pg_size_pretty(pg_total_relation_size(relid) – pg_relation_size(relid)) as "External Size"
FROM pg_catalog.pg_statio_user_tables ORDER BY pg_total_relation_size(relid) DESC;
ShellScript

Leave a Reply

Your email address will not be published. Required fields are marked *

search previous next tag category expand menu location phone mail time cart zoom edit close