diff --git a/operators/postgres.md b/operators/postgres.md index 87ba8a87c9537307082ad7189555d9f13266bde7..52e214da3fca1f6e32c6f611307443e8c30bfdf1 100644 --- a/operators/postgres.md +++ b/operators/postgres.md @@ -50,3 +50,39 @@ By default spilo postgres is configured with: If logs are eating space, you can change it to off in the crd. +### List postgres table orederd by size + +``` +SELECT + table_name, + pg_size_pretty( pg_total_relation_size(quote_ident(table_name))), + pg_total_relation_size(quote_ident(table_name)) +FROM + information_schema.tables +WHERE + table_schema = 'public' +ORDER BY + pg_total_relation_size(quote_ident(table_name)) DESC +; +``` + +### Show index size of table + +``` +SELECT + pg_size_pretty (pg_indexes_size('table_name')); +``` + +### Show indexes of table + +``` +select * +from pg_indexes +where tablename = 'table_name'; +``` + +### ReIndex all the indexes + +``` +REINDEX INDEX indexname +```