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. + + + + A prepared statement is executed in a CREATE TABLE .. AS + EXECUTE .. statement. + + 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);