在从v9.6升级到v12的pg_upgrade之后清空表



我使用此命令将postgresql数据库从v9.6升级到v12:

/opt/rh/rh-postgresql12/root/usr/bin/pg_upgrade -b /opt/rh/rh-postgresql96/root/usr/bin/ -B /opt/rh/rh-postgresql12/root/usr/bin/ -d /var/opt/rh/rh-postgresql96/lib/pgsql/data  -D /var/opt/rh/rh-postgresql12/lib/pgsql/data 

我没有遇到任何错误,升级也很成功,但当我试图从数据库中提取一些数据时,我意识到所有的数据库表都是空的。数据库的大小在某种程度上与旧数据库相同,运行以下命令返回所有表,但有0行:

select n.nspname as table_schema,c.relname as table_name, c.reltuples as rows 
from pg_class c 
join pg_namespace n on n.oid = c.relnamespace 
where c.relkind = 'r' 
and n.nspname not in ('information_schema','pg_catalog') 
order by c.reltuples desc;

你能告诉我为什么这些桌子没有排吗?

通过postgresql运行建议的脚本:'/var/lib/pgsql/analyze_new_cluster.sh'

命令

sudo -u postgres /opt/rh/rh-postgresql12/root/usr/bin/vacuumdb --all --analyze-in-stages -p 5433

会解决这个问题。

相关内容

最新更新