pg_restore taking much longer than pg_dump

Solution 1:

The content of an index is not part of the backup, only the definition of the index. And that will only take a few bytes. When the index is created during restore and all data is indexed, it will be much bigger. This will take time, but it depends on your situation how much time.

pg_restore does have an option for concurrent restore (as of version 8.4), use --jobs=number-of-jobs

Solution 2:

For a restore, the database has to do a lot of additional work:

Some things come to mind immediately:

  • Writing is slower than reading
  • Parsing the input takes time
  • Updating indexes and other internal structures
  • Maintaining referential integrity

Not sure if this amounts to that time difference, though.