prepared_stmt_parallel_query_v4.patch
application/octet-stream
Filename: prepared_stmt_parallel_query_v4.patch
Type: application/octet-stream
Part: 0
Patch
Same data as JSON:
GET /api/v1/attachments/:id/patch
the parsed metadata as JSON — format, series position, per-file stats; never the diff bytes.
API reference →
Format: unified
Series: patch v4
| File | + | − |
|---|---|---|
| doc/src/sgml/parallel.sgml | 7 | 0 |
| src/backend/commands/prepare.c | 1 | 1 |
| src/backend/executor/execMain.c | 4 | 3 |
diff --git a/doc/src/sgml/parallel.sgml b/doc/src/sgml/parallel.sgml
index d0b438e..aa4a2dd 100644
--- a/doc/src/sgml/parallel.sgml
+++ b/doc/src/sgml/parallel.sgml
@@ -220,6 +220,13 @@ EXPLAIN SELECT * FROM pgbench_accounts WHERE filler LIKE '%x%';
<listitem>
<para>
+ A prepared statement is executed in a <literal>CREATE TABLE .. AS
+ EXECUTE ..</literal> statement.
+ </para>
+ </listitem>
+
+ <listitem>
+ <para>
The transaction isolation level is serializable. This situation
does not normally arise, because parallel query plans are not
generated when the transaction isolation level is serializable.
diff --git a/src/backend/commands/prepare.c b/src/backend/commands/prepare.c
index cec37ce..b01051d 100644
--- a/src/backend/commands/prepare.c
+++ b/src/backend/commands/prepare.c
@@ -159,7 +159,7 @@ PrepareQuery(PrepareStmt *stmt, const char *queryString)
nargs,
NULL,
NULL,
- 0, /* default cursor options */
+ CURSOR_OPT_PARALLEL_OK, /* allow parallel mode */
true); /* fixed result */
/*
diff --git a/src/backend/executor/execMain.c b/src/backend/executor/execMain.c
index 32bb3f9..71c0728 100644
--- a/src/backend/executor/execMain.c
+++ b/src/backend/executor/execMain.c
@@ -1540,10 +1540,11 @@ ExecutePlan(EState *estate,
estate->es_direction = direction;
/*
- * If a tuple count was supplied, we must force the plan to run without
- * parallelism, because we might exit early.
+ * If a tuple count was supplied or data is being written to relation, we
+ * must force the plan to run without parallelism, because we might exit
+ * early.
*/
- if (numberTuples)
+ if (numberTuples || dest->mydest == DestIntoRel)
use_parallel_mode = false;
/*