Question

If I run pg_dump to dump a table into a SQL file, does it take a snapshot of the last row in the table, and dump all the rows up to this row?

Or does it keep dumping all the rows, even those that were inserted after pg_dump was ran?

A secondary question is: Is it a good idea to stop all insert queries before running pg_dump?

Was it helpful?

Solution

It will obtain a shared lock on your tables when you run the pg_dump. Any transactions completed after you run the dump will not be included. So when the dump is finished, if there are current transactions in process that haven't been committed, they won't be included in the dump.

There is another param with which it can be run that says this

--lock-wait-timeout=timeout Do not wait forever to acquire shared table locks at the beginning of the dump. Instead fail if unable to lock a table within the specified timeout. The timeout may be specified in any of the formats accepted by SET statement_timeout. (Allowed values vary depending on the server version you are dumping from, but an integer number of milliseconds is accepted by all versions since 7.3. This option is ignored when dumping from a pre-7.3 server.)**

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top