Skip to content

Commit 5674a25

Browse files
committed
plpgsql: Don't generate parallel plans for RETURN QUERY.
Commit 7aea8e4 allowed a parallel plan to be generated when for a RETURN QUERY or RETURN QUERY EXECUTE statement in a PL/pgsql block, but that's a bad idea because plplgsql asks the executor for 50 rows at a time. That means that we'll always be running serially a plan that was intended for parallel execution, which is not a good idea. Fix by not requesting a parallel plan from the outset. Per discussion, back-patch to 9.6. There is a slight risk that, due to optimizer error, somebody could have a case where the parallel plan executed serially is actually faster than the supposedly-best serial plan, but the consensus seems to be that that's not sufficient justification for leaving 9.6 unpatched. Discussion: http://postgr.es/m/CA+TgmoZ_ZuH+auEeeWnmtorPsgc_SmP+XWbDsJ+cWvWBSjNwDQ@mail.gmail.com Discussion: http://postgr.es/m/CA+TgmobXEhvHbJtWDuPZM9bVSLiTj-kShxQJ2uM5GPDze9fRYA@mail.gmail.com
1 parent 2ed391f commit 5674a25

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/pl/plpgsql/src/pl_exec.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2870,15 +2870,15 @@ exec_stmt_return_query(PLpgSQL_execstate *estate,
28702870
if (stmt->query != NULL)
28712871
{
28722872
/* static query */
2873-
exec_run_select(estate, stmt->query, 0, &portal, true);
2873+
exec_run_select(estate, stmt->query, 0, &portal, false);
28742874
}
28752875
else
28762876
{
28772877
/* RETURN QUERY EXECUTE */
28782878
Assert(stmt->dynquery != NULL);
28792879
portal = exec_dynquery_with_params(estate, stmt->dynquery,
28802880
stmt->params, NULL,
2881-
CURSOR_OPT_PARALLEL_OK);
2881+
0);
28822882
}
28832883

28842884
tupmap = convert_tuples_by_position(portal->tupDesc,

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy