Re: [WIP PATCH v2] Implement "pg_restore --data-only --clean" as a way to skip WAL - Mailing list pgsql-hackers

From Dimitrios Apostolou
Subject Re: [WIP PATCH v2] Implement "pg_restore --data-only --clean" as a way to skip WAL
Date
Msg-id 850fc61f-be21-1993-b23d-6d8235978b63@gmx.net
Whole thread Raw
In response to [WIP PATCH v2] Implement "pg_restore --data-only --clean" as a way to skip WAL  (Dimitrios Apostolou <jimis@gmx.net>)
List pgsql-hackers
I wonder about the following in pg_restore.c.
Right now my implementation covers only parallel restore.
In the case of non-parallel restore, I want to make the behaviour
similar, i.e. each worker to issue a TRUNCATE before COPY starts.
But then the StartTransaction() doesn't make sense, as everything might
already be in a transaction because of --single-transaction.
Should I completely skip StartTransaction() if !is_parallel?



-                                       use_truncate = is_parallel && te->created &&
+                                       use_truncate = is_parallel &&
+                                               (te->created || (ropt->dumpData && ropt->clean)) &&
                                                 !is_load_via_partition_root(te);

                                         if (use_truncate)
                                         {
+                                               pg_log_debug("BEGIN transaction and TRUNCATE table \"%s.%s\"",
+                                                                        te->namespace, te->tag);
+
                                                 /*
                                                  * Parallel restore is always talking directly to a
                                                  * server, so no need to see if we should issue BEGIN.
                                                  */
                                                 StartTransaction(&AH->public);

                                                 /*
                                                  * Issue TRUNCATE with ONLY so that child tables are
                                                  * not wiped.
                                                  */
                                                 ahprintf(AH, "TRUNCATE TABLE ONLY %s;\n\n",
                                                                  fmtQualifiedId(te->namespace, te->tag));







pgsql-hackers by date:

Previous
From: Nathan Bossart
Date:
Subject: Re: pg_dump --with-* options
Next
From: Robert Haas
Date:
Subject: Re: pg_dump --with-* options