Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Postgres Replication and Temporary Tables

If I create a temporary table inside of a transaction, populate it with the COPY command, and use the ON COMMIT DROP option, does the table data still get written to the WAL and get replicated to the slave database? I'm doing a fairly large import, doing some work using that data, and then I don't need it anymore. I don't want to rollback the whole transaction because I want to keep the work that was done using the source data, but I won't need the source data again and so I don't want to waste time and bandwidth replicating and deleting it on the slave.

like image 722
Michael Payne Avatar asked Jan 19 '23 07:01

Michael Payne


1 Answers

Temporary tables are not WAL-logged in PostgreSQL.

You might be interested in this article by Robert Haas (PostgreSQL core developer) about unlogged tables - that also clarifies the behavior of temporary tables.

like image 56
Erwin Brandstetter Avatar answered Feb 21 '23 04:02

Erwin Brandstetter