Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit4212cb7

Browse files
committed
Fix interaction of parallel query with prepared statements.
Previously, a prepared statement created via a Parse message could geta parallel plan, but one created with a PREPARE statement could not.This state of affairs was due to confusion on my (rhaas) part: Ierroneously believed that a CREATE TABLE .. AS EXECUTE statement couldonly be performed with a prepared statement by PREPARE, but in factone created by a Prepare message works just as well. Therefore, itmakes no sense to allow parallel query in one case but not the other.To fix, allow parallel query with all prepared statements, but runthe parallel plan serially (i.e. without workers) in the case ofCREATE TABLE .. AS EXECUTE. Also, document this.Amit Kapila and Tobias Bussman, plus an extra sentence ofdocumentation by me.
1 parentcb9dcbc commit4212cb7

File tree

3 files changed

+14
-4
lines changed

3 files changed

+14
-4
lines changed

‎doc/src/sgml/parallel.sgml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,15 @@ EXPLAIN SELECT * FROM pgbench_accounts WHERE filler LIKE '%x%';
227227
</para>
228228
</listitem>
229229

230+
<listitem>
231+
<para>
232+
A prepared statement is executed using a <literal>CREATE TABLE .. AS
233+
EXECUTE ..</literal> statement. This construct converts what otherwise
234+
would have been a read-only operation into a read-write operation,
235+
making it ineligible for parallel query.
236+
</para>
237+
</listitem>
238+
230239
<listitem>
231240
<para>
232241
The transaction isolation level is serializable. This situation

‎src/backend/commands/prepare.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ PrepareQuery(PrepareStmt *stmt, const char *queryString)
159159
nargs,
160160
NULL,
161161
NULL,
162-
0,/*default cursor options */
162+
CURSOR_OPT_PARALLEL_OK,/*allow parallel mode */
163163
true);/* fixed result */
164164

165165
/*

‎src/backend/executor/execMain.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1540,10 +1540,11 @@ ExecutePlan(EState *estate,
15401540
estate->es_direction=direction;
15411541

15421542
/*
1543-
* If a tuple count was supplied, we must force the plan to run without
1544-
* parallelism, because we might exit early.
1543+
* If a tuple count was supplied or data is being written to relation, we
1544+
* must force the plan to run without parallelism, because we might exit
1545+
* early.
15451546
*/
1546-
if (numberTuples)
1547+
if (numberTuples||dest->mydest==DestIntoRel)
15471548
use_parallel_mode= false;
15481549

15491550
/*

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp