prepared_stmt_execute_parallel_query.patch
application/octet-stream
Filename: prepared_stmt_execute_parallel_query.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
| File | + | − |
|---|---|---|
| doc/src/sgml/parallel.sgml | 7 | 0 |
| src/backend/commands/prepare.c | 11 | 1 |
diff --git a/doc/src/sgml/parallel.sgml b/doc/src/sgml/parallel.sgml
index d0b438e..b97f241 100644
--- a/doc/src/sgml/parallel.sgml
+++ b/doc/src/sgml/parallel.sgml
@@ -217,6 +217,13 @@ EXPLAIN SELECT * FROM pgbench_accounts WHERE filler LIKE '%x%';
be suboptimal when run serially.
</para>
</listitem>
+
+ <listitem>
+ <para>
+ A prepared statement is executed in a <literal>CREATE TABLE .. AS
+ EXECUTE ..</literal> statement.
+ </para>
+ </listitem>
<listitem>
<para>
diff --git a/src/backend/commands/prepare.c b/src/backend/commands/prepare.c
index cec37ce..44a3eee 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 */
/*
@@ -271,6 +271,10 @@ ExecuteQuery(ExecuteStmt *stmt, IntoClause *intoClause,
count = 0;
else
count = FETCH_ALL;
+
+ /* Disable parallel query as this is executed as DML */
+ pstmt->parallelModeNeeded = false;
+
}
else
{
@@ -665,7 +669,13 @@ ExplainExecuteQuery(ExecuteStmt *execstmt, IntoClause *into, ExplainState *es,
PlannedStmt *pstmt = (PlannedStmt *) lfirst(p);
if (IsA(pstmt, PlannedStmt))
+ {
+ if (into)
+ /* Disable parallel query as this is executed as DML */
+ pstmt->parallelModeNeeded = false;
+
ExplainOnePlan(pstmt, into, es, query_string, paramLI, NULL);
+ }
else
ExplainOneUtility((Node *) pstmt, into, es, query_string, paramLI);