sysadmin:postgresql
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
sysadmin:postgresql [2014/11/25 09:38] – [Occupazione disco per tabelle] - tolto LIMIT 20 feroda | sysadmin:postgresql [Unknown date] (current) – removed - external edit (Unknown date) 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== PostgreSQL - Basi di configurazione ====== | ||
- | |||
- | - eseguire ''/ | ||
- | - installare '' | ||
- | - eseguire '' | ||
- | - abilitare i log su stderr seguendo la documentazione di [[http:// | ||
- | - NOTA LOG: attualmente su befair2 i log sono in ''/ | ||
- | ====== Performance ====== | ||
- | |||
- | * Performance Tuning: http:// | ||
- | * Ottimo articolo segnalato da AndreaF http:// | ||
- | * Index Maintenance https:// | ||
- | |||
- | |||
- | ===== Query utili su indici e loro utilizzo | ||
- | |||
- | Indici presenti | ||
- | |||
- | [0] SELECT * FROM pg_indexes; | ||
- | |||
- | ==== Ricerca indici doppi ==== | ||
- | |||
- | Query " | ||
- | |||
- | acs_service=# | ||
- | | ||
- | Query appropriata da http:// | ||
- | |||
- | [1] select indrelid:: | ||
- | |||
- | Nota: richiede di definire l' | ||
- | |||
- | ==== Utilizzo degli indici ==== | ||
- | |||
- | Utilizzo degli indici | ||
- | | ||
- | SELECT relid, | ||
- | |||
- | Filtra solo quelli utilizzati almeno una volta | ||
- | | ||
- | SELECT * from pg_stat_all_indexes WHERE relname=' | ||
- | | ||
- | Filtra solo quelli che sono stati efficaci almeno una volta | ||
- | |||
- | SELECT * from pg_stat_all_indexes WHERE schemaname=' | ||
- | | ||
- | Query più appropriata, | ||
- | |||
- | [2] select indexrelid:: | ||
- | |||
- | Ho modificato la query per trovare gli indici che sono stati efficaci almeno una volta: | ||
- | |||
- | [3] select indexrelid:: | ||
- | |||
- | Invece questa la query per indici usati senza essere efficaci | ||
- | |||
- | [4] select indexrelid:: | ||
- | |||
- | ===== Query per tabelle ===== | ||
- | |||
- | Tabelle vuote (stima. Per una risposta esaustiva vedere http:// | ||
- | |||
- | [5] SELECT schemaname, | ||
- | |||
- | ===== Esecuzione query al ... ===== | ||
- | |||
- | * [0] = ... indici totali | ||
- | * [1] = ... indici doppi | ||
- | * [2] = ... indici non usati | ||
- | * [3] = ... indici che sono stati efficaci | ||
- | * [4] = ... indici usati ma non efficaci | ||
- | * [5] = ... tabelle vuote | ||
- | |||
- | ====== Occupazione disco per 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 ===== | ||
- | |||
- | * Processi attivi: '' | ||
- | * Utilizzo delle tabelle: '' | ||
- | * Lock da https:// | ||
- | |||
- | |||
- | SELECT a.datname, | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | FROM pg_stat_activity a | ||
- | JOIN pg_locks | ||
- | JOIN pg_class | ||
- | WHERE mode=' | ||
- | |||
- | ===== Avvio manuale di postgres ===== | ||
- | |||
- | se service postgresql start offre poca flessibilità usare | ||
- | |||
- | pg_ctlcluster 8.4 main start -- -w | ||
- | | ||
- | o ancora più a basso livello, da utente '' | ||
- | |||
- | / | ||