原 迁移GreenPlum中gpperfmon库
Tags: 原创GreenPlum数据迁移gpperfmon
简介
若从GP6升级到GP7,为了保留数据库历史性能数据,用来做升级或迁移后的性能数据比对,我们需要备份gpperfmon库。
清理不需要的数据
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | truncate table gpmetrics.gpcc_plannode_history; truncate table gpmetrics.gpcc_ps_history; truncate table gpmetrics.gpcc_resgroup_history; truncate table gpmetrics.gp_log_master_history; -- 大表 SELECT t.table_catalog as db, n.nspname AS schemaname, c.relname, c.reltuples::numeric as rowcount, pg_size_pretty(pg_table_size ( '"' || nspname || '"."' || relname || '"' )) AS table_size, pg_size_pretty(pg_indexes_size ( '"' || nspname || '"."' || relname || '"' )) AS indexes_size, pg_size_pretty (pg_total_relation_size ( '"' || nspname || '"."' || relname || '"' )) AS total_size --,pg_relation_filepath(table_name) filepath FROM pg_class C LEFT JOIN pg_namespace N ON ( N.oid = C.relnamespace ) left join information_schema.tables t on (n.nspname= t.table_schema and c.relname=t."table_name" ) where nspname NOT IN ( 'information_schema','gp_toolkit' ) AND relkind in ('r','p') ORDER BY pg_total_relation_size ( '"' || nspname || '"."' || relname || '"' ) DESC LIMIT 50; |