pg_restore忽略-j参数

时间:2018-04-10 14:17:18

标签: postgresql-9.2 pg-restore

我有一个相当大的数据库(15G +压缩):

pg_dump wrwks_prod -Fc -f /path/to/file.dump

并恢复到这样的远程主机:

pg_restore --no-owner --clean --dbname=dbname --username=user --host=remote_host --port=port  -j 3 --v /path/to/file.dump

但是当我检查远程计算机时,只有一个进程使用一个核心来创建索引,因此忽略了jobs参数。

这可能是什么原因?

本地和远程计算机都使用Postgres 9.2运行。

1 个答案:

答案 0 :(得分:0)

我认为你有一个巨大的表,上面有一个巨大的索引,因此并行作业可以非常快速地恢复所有其余的小关系。在表完全恢复之前,索引构建无法启动,因此它会等待它。一旦表恢复,就会创建一个巨大的索引...当然这是一个假设...... 尝试运行smth,如:

SELECT oid, row_estimate, total_bytes
    ,pg_size_pretty(total_bytes) AS total
    , pg_size_pretty(index_bytes) AS INDEX
    , pg_size_pretty(toast_bytes) AS toast
    , pg_size_pretty(table_bytes) AS tbl
  FROM (
  SELECT *, total_bytes-index_bytes-COALESCE(toast_bytes,0) AS table_bytes FROM (
      SELECT c.oid,nspname AS table_schema, relname AS TABLE_NAME
              , c.reltuples AS row_estimate
              , pg_total_relation_size(c.oid) AS total_bytes
              , pg_indexes_size(c.oid) AS index_bytes
              , pg_total_relation_size(reltoastrelid) AS toast_bytes
          FROM pg_class c
          LEFT JOIN pg_namespace n ON n.oid = c.relnamespace
          WHERE relkind = 'r'
  ) a
) a
order by "total_bytes" desc
limit 10
;

确认或忽略假设