#!/bin/bash
#script: sys_table_vacuum.sh
echo "[`date`] Start <vacuum analyze> systables ..."
psql -d mydb -tc "select 'vacuum analyze '||b.nspname||'.'||a.relname||' ;' from pg_class a, pg_namespace b where b.nspname in ('pg_toast','pg_bitmapindex','pg_aoseg','pg_catalog','information_schema') and a.relnamespace=b.oid and a.relkind='r' " | psql -d mydb -a
echo "[`date`] End ..."
注:这里排除了gp_toolkit等包含视图的模式名,只保留普通表的模式名。