sysadmin:postgresql
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
sysadmin:postgresql [2014/11/05 10:04] – indici totali nel report feroda | sysadmin:postgresql [2014/11/25 17:17] – occupazione db feroda | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== Basi di configurazione ====== | + | ====== |
- eseguire ''/ | - eseguire ''/ | ||
Line 71: | Line 71: | ||
* [4] = ... indici usati ma non efficaci | * [4] = ... indici usati ma non efficaci | ||
* [5] = ... tabelle vuote | * [5] = ... tabelle vuote | ||
+ | |||
+ | ====== Occupazione disco ====== | ||
+ | |||
+ | ===== Database ===== | ||
+ | |||
+ | Lo restituisce pure in formato carino :) | ||
+ | |||
+ | # select (pg_database_size(current_database())/ | ||
+ | |||
+ | ===== Tabelle ===== | ||
+ | |||
+ | Restituisce un elenco ordinato in modo discendente di: | ||
+ | |||
+ | * schema (aka " | ||
+ | * tabella | ||
+ | * occupazione su disco | ||
+ | * occupazione totale compresi indici | ||
+ | * numero stimato di righe | ||
+ | |||
+ | SELECT table_schema, | ||
+ | (size/ | ||
+ | (total_size/ | ||
+ | (CASE WHEN pg_class.reltuples > 0 THEN | ||
+ | basic_infos.size/ | ||
+ | ELSE 0 | ||
+ | END | ||
+ | )::bigint AS estimated_row_count | ||
+ | FROM ( | ||
+ | SELECT table_schema, | ||
+ | pg_relation_size('"' | ||
+ | pg_total_relation_size('"' | ||
+ | FROM information_schema.tables | ||
+ | WHERE table_schema NOT IN (' | ||
+ | ORDER BY size DESC, total_size DESC | ||
+ | ) AS basic_infos | ||
+ | JOIN pg_class | ||
+ | ON ('"' | ||
+ | |||
+ | Questa query funziona su PostgreSQL 8.4. E credo valga anche per PostgreSQL >= 9.0. Potrebbe essere interessante pubblicarla da qualche parte. | ||
+ | |||
+ | |||
+ | ====== Informazioni varie... ====== | ||
===== Query comode x debug ===== | ===== Query comode x debug ===== |