Очистка данных удаленных инстансов в БД платформы Tantor
Проблема:
База увеличилась в размере.
Решение:
Для очистки Базы Даных сервера платформы от накопившегося мусора можно выполнить следующие команды:
docker exec -it db psql -U postgres -p 5432 pma
BASH
далее:
set pipelinedb.matrels_writable to true;
select pg_reload_conf();
delete from monitoring.cv_metric_pg_stat_statements_sum where instance_id not in (select instance_id from core.instances);
delete from monitoring.cv_metric_pg_stat_statements_sum_5m where instance_id not in (select instance_id from core.instances);
delete from monitoring.cv_metric_pg_stat_statements_sum_10m where instance_id not in (select instance_id from core.instances);
delete from monitoring.cv_metric_pg_stat_statements_sum_30m where instance_id not in (select instance_id from core.instances);
delete from monitoring.cv_metric_pg_stat_statements_query where instance_id not in (select instance_id from core.instances);
delete from monitoring.cv_metric_blocks_io where instance_id not in (select instance_id from core.instances);
delete from monitoring.cv_metric_dbsize_total where instance_id not in (select instance_id from core.instances);
delete from monitoring.cv_metric_query_avg where instance_id not in (select instance_id from core.instances);
delete from monitoring.cv_metric_query_databases where instance_id not in (select instance_id from core.instances);
delete from monitoring.cv_metric_query_sum where instance_id not in (select instance_id from core.instances);
delete from monitoring.cv_metric_top5_queries_tt30m where instance_id not in (select instance_id from core.instances);
delete from monitoring.cv_metric_top5_queries_tt1h where instance_id not in (select instance_id from core.instances);
delete from monitoring.cv_metric_top5_queries_tt3h where instance_id not in (select instance_id from core.instances);
delete from monitoring.cv_metric_top5_queries_tt8h where instance_id not in (select instance_id from core.instances);
delete from monitoring.cv_metric_top5_queries_tt12h where instance_id not in (select instance_id from core.instances);
delete from monitoring.cv_metric_top5_queries_tt1d where instance_id not in (select instance_id from core.instances);
delete from monitoring.cv_metric_top5_queries_tt7d where instance_id not in (select instance_id from core.instances);
delete from monitoring.v_metric_bgwriter where instance_id not in (select instance_id from core.instances);
delete from monitoring.v_metric_blocks where instance_id not in (select instance_id from core.instances);
delete from monitoring.v_metric_blocks_dbs where instance_id not in (select instance_id from core.instances);
delete from monitoring.v_metric_checkpoints where instance_id not in (select instance_id from core.instances);
delete from monitoring.v_metric_deadlocks_conflicts_checksums where instance_id not in (select instance_id from core.instances);
delete from monitoring.v_metric_pg_stat_wal_receiver where instance_id not in (select instance_id from core.instances);
delete from monitoring.v_metric_replication_primary where instance_id not in (select instance_id from core.instances);
delete from monitoring.v_metric_session_dbs where instance_id not in (select instance_id from core.instances);
delete from monitoring.v_metric_tempfiles where instance_id not in (select instance_id from core.instances);
delete from monitoring.v_metric_tps where instance_id not in (select instance_id from core.instances);
delete from monitoring.v_metric_tps_sum where instance_id not in (select instance_id from core.instances);
delete from monitoring.v_metric_tuples where instance_id not in (select instance_id from core.instances);
delete from monitoring.v_metric_waiting_locks where instance_id not in (select instance_id from core.instances);
delete from monitoring.v_metric_wal_files_archive where instance_id not in (select instance_id from core.instances);
delete from monitoring.v_metric_wal_files where instance_id not in (select instance_id from core.instances);
delete from monitoring.v_metric_wal_files_raw where instance_id not in (select instance_id from core.instances);
delete from monitoring.v_metric_wraparound_stats where instance_id not in (select instance_id from core.instances);
delete from monitoring.v_metric_locks where instance_id not in (select instance_id from core.instances);
delete from monitoring.v_metric_replication_lag where instance_id not in (select instance_id from core.instances);
delete from monitoring.v_metric_cpu_load where host_id not in (select host_id from core.instances);
delete from monitoring.v_metric_processes where host_id not in (select host_id from core.instances);
delete from monitoring.v_metric_processes_sum where host_id not in (select host_id from core.instances);
delete from monitoring.v_metric_swap_info where host_id not in (select host_id from core.instances);
delete from monitoring.v_metric_net_io_persec where host_id not in (select host_id from core.instances);
delete from monitoring.v_metric_net_io where host_id not in (select host_id from core.instances);
delete from monitoring.v_metric_memory_info where host_id not in (select host_id from core.instances);
delete from monitoring.v_metric_disk_io where host_id not in (select host_id from core.instances);
delete from monitoring.v_metric_disk_io_sum where host_id not in (select host_id from core.instances);
delete from monitoring.v_metric_agent_availability where host_id not in (select host_id from core.instances);
delete from monitoring.cv_metric_replication_info where host_id not in (select host_id from core.instances);
delete from monitoring.v_metric_postgresql_availability where host_id not in (select host_id from core.instances);
delete from monitoring.v_metric_server_uptime where host_id not in (select host_id from core.instances);
delete from profiler.cv_pg_store_plans where instance_id not in (select instance_id from core.instances);
delete from profiler.cv_pg_store_plans5m where instance_id not in (select instance_id from core.instances);
delete from profiler.cv_pg_store_plans10m where instance_id not in (select instance_id from core.instances);
delete from profiler.cv_pg_store_plans30m where instance_id not in (select instance_id from core.instances);
delete from profiler.cv_pg_store_plans_text where instance_id not in (select instance_id from core.instances);
BASH