diff --git a/doc/src/sgml/parallel.sgml b/doc/src/sgml/parallel.sgml index f39c21a4550..cf4c1c9c2a9 100644 --- a/doc/src/sgml/parallel.sgml +++ b/doc/src/sgml/parallel.sgml @@ -227,6 +227,15 @@ EXPLAIN SELECT * FROM pgbench_accounts WHERE filler LIKE '%x%'; + + + A prepared statement is executed using a CREATE TABLE .. AS + EXECUTE .. statement. This construct converts what otherwise + would have been a read-only operation into a read-write operation, + making it ineligible for parallel query. + + + The transaction isolation level is serializable. This situation diff --git a/src/backend/commands/prepare.c b/src/backend/commands/prepare.c index cec37ce0405..b01051df9d2 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 32bb3f92054..71c07288a19 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; /*