Allow parallelism in COPY (query) TO ...;
authorAndres Freund <andres@anarazel.de>
Sat, 3 Jun 2017 02:05:57 +0000 (19:05 -0700)
committerAndres Freund <andres@anarazel.de>
Sat, 3 Jun 2017 02:11:23 +0000 (19:11 -0700)
Previously this was not allowed, as copy.c didn't set the
CURSOR_OPT_PARALLEL_OK flag when planning the query. Set it.

While the lack of parallel query for COPY isn't strictly speaking a
bug, it does prevent parallelism from being used in a facility
commonly used to run long running queries. Thus backpatch to 9.6.

Author: Andres Freund
Discussion: https://postgr.es/m/20170531231958.ihanapplorptykzm@alap3.anarazel.de
Backpatch: 9.6, where parallelism was introduced.

src/backend/commands/copy.c

index db6ef783145d2893ebb87c388fefe5cb80483b1d..41a828c2fe44788a10138f8e11e562b73816c56b 100644 (file)
@@ -1491,7 +1491,7 @@ BeginCopy(bool is_from,
        }
 
        /* plan the query */
-       plan = pg_plan_query(query, 0, NULL);
+       plan = pg_plan_query(query, CURSOR_OPT_PARALLEL_OK, NULL);
 
        /*
         * With row level security and a user using "COPY relation TO", we