PostgreSQL XML dump
Posted by gregster on 31 Jan 2020 in Announcements
PostgreSQL (psql) has several xml output methods.
For example, to dump a table to an XML file:
# /usr/pgsql-9.6/bin/psql -v ON_ERROR_STOP=1 -d name_of_db name_of_db=# COPY (SELECT table_to_xml('name_of_schema.name_of_table', true, false, '')) to '/path/to/backup.xml'
There are two problems with using XML outputs:
1) The XML is pretty basic
2) Because of the way PostgreSQL works the whole transaction is done at once so memory allocation on large tables will kill the process (or the server) and you end up with messages like this:
server closed the connection unexpectedly
This probably means the server terminated abnormally
before or while processing the request.
The connection to the server was lost. Attempting reset: Failed.
The advice from sysadmin is don't use XML output for big things.
This entry was posted by Greg and filed under Announcements.