[MASSMAIL]pgsql: Invent --transaction-size option for pg_restore.

Поиск
Список
Период
Сортировка
От Tom Lane
Тема [MASSMAIL]pgsql: Invent --transaction-size option for pg_restore.
Дата
Msg-id E1rrOYC-00020N-4k@gemulon.postgresql.org
обсуждение исходный текст
Список pgsql-committers
Invent --transaction-size option for pg_restore.

This patch allows pg_restore to wrap its commands into transaction
blocks, somewhat like --single-transaction, except that we commit
and start a new block after every N objects.  Using this mode
with a size limit of 1000 or so objects greatly reduces the number
of transactions consumed by the restore, while preventing any
one transaction from taking enough locks to overrun the receiving
server's shared lock table.

(A value of 1000 works well with the default lock table size of
around 6400 locks.  Higher --transaction-size values can be used
if one has increased the receiving server's lock table size.)

Excessive consumption of XIDs has been reported as a problem for
pg_upgrade in particular, but it could be bad for any restore; and the
change also reduces the number of fsyncs and amount of WAL generated,
so it should provide speed benefits too.

This patch does not try to make parallel workers batch the SQL
commands they issue.  The trouble with doing that is that other
workers may need to see the objects a worker creates right away.
Possibly this can be improved later.

In this patch I have hard-wired pg_upgrade to use a transaction size
of 1000 divided by the number of parallel restore jobs allowed
(without that, we'd still be at risk of overrunning the shared lock
table).  Perhaps there would be value in adding another pg_upgrade
option to allow user control of that, but I'm unsure that it's worth
the trouble; I think few users would use it, and any who did would see
not that much benefit compared to the default.

Patch by me, but the original idea to batch SQL commands during
restore is due to Robins Tharakan.

Discussion: https://postgr.es/m/a9f9376f1c3343a6bb319dce294e20ac@EX13D05UWC001.ant.amazon.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/959b38d770ba1f8f35edab27ef3ccf8b1d99f5dd

Modified Files
--------------
doc/src/sgml/ref/pg_restore.sgml     |  24 ++++++
src/bin/pg_dump/pg_backup.h          |   4 +-
src/bin/pg_dump/pg_backup_archiver.c | 139 +++++++++++++++++++++++++++++++++--
src/bin/pg_dump/pg_backup_archiver.h |   3 +
src/bin/pg_dump/pg_backup_db.c       |  18 +++++
src/bin/pg_dump/pg_restore.c         |  15 +++-
src/bin/pg_upgrade/pg_upgrade.c      |  25 +++++++
7 files changed, 220 insertions(+), 8 deletions(-)


В списке pgsql-committers по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: [MASSMAIL] pgsql: Avoid possible longjmp-induced logic error in PLy_trigger_build_
Следующее
От: Heikki Linnakangas
Дата:
Сообщение: [MASSMAIL]pgsql: Introduce 'options' argument to heap_page_prune()