Skip to content

Commit f120b61

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 857ee8e commit f120b61

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
@@ -3023,15 +3023,15 @@ exec_stmt_return_query(PLpgSQL_execstate *estate,
30233023
if (stmt->query != NULL)
30243024
{
30253025
/* static query */
3026-
exec_run_select(estate, stmt->query, 0, &portal, true);
3026+
exec_run_select(estate, stmt->query, 0, &portal, false);
30273027
}
30283028
else
30293029
{
30303030
/* RETURN QUERY EXECUTE */
30313031
Assert(stmt->dynquery != NULL);
30323032
portal = exec_dynquery_with_params(estate, stmt->dynquery,
30333033
stmt->params, NULL,
3034-
CURSOR_OPT_PARALLEL_OK);
3034+
0);
30353035
}
30363036

30373037
/* Use eval_mcontext for tuple conversion work */

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