首页 > 解决方案 > Postgres 导入问题 - 巨大的表显示 0 行

问题描述

我有一个数据库导入问题。基本上,我在 postgres 9.6(生产)上这样做:

/usr/bin/pg_dump  mydb | /bin/gzip | /usr/bin/ssh root@1.2.3.4 "cat > /root/20210130.sql.gz"

在远程机器上,我正在像这样在 Postgres 11 上导入:

step 1: import schema from a beta machine with Postgres 11
step 2: import data from that export like this: time zcat 20210130.sql.gz | psql mydb 

我遇到的问题是其中一张表有 0 行,即使它使用了大量磁盘空间。

在原始数据库中:

    table_schema    |        table_name        | row_estimate |   total    |   index    |   toast    |   table    
--------------------+--------------------------+--------------+------------+------------+------------+------------
 public             | test                     |   5.2443e+06 | 18 GB      | 13 GB      | 8192 bytes | 4864 MB

在新数据库中:

    table_schema    |        table_name        | row_estimate |   total    |   index    |   toast    |   table
--------------------+--------------------------+--------------+------------+------------+------------+------------
 public             | test                     |            0 | 4574 MB    | 4574 MB    | 8192 bytes | 16 kB

这里发生了什么?我该如何解决?

我无法再次导入整个数据库,因为导入需要大约 7 个小时。

标签: postgresqlpostgresql-9.6pg-dumppostgresql-11

解决方案


推荐阅读