diff --git a/src/backend/executor/functions.c b/src/backend/executor/functions.c
index 2d49a65650..5ce6a3ddca 100644
--- a/src/backend/executor/functions.c
+++ b/src/backend/executor/functions.c
@@ -503,7 +503,7 @@ init_execution_state(List *queryTree_list,
 			}
 			else
 				stmt = pg_plan_query(queryTree,
-						  fcache->readonly_func ? CURSOR_OPT_PARALLEL_OK : 0,
+						  CURSOR_OPT_PARALLEL_OK,
 									 NULL);
 
 			/*
diff --git a/src/backend/executor/spi.c b/src/backend/executor/spi.c
index 55f97b14e6..1f6e669327 100644
--- a/src/backend/executor/spi.c
+++ b/src/backend/executor/spi.c
@@ -314,7 +314,7 @@ SPI_execute(const char *src, bool read_only, long tcount)
 
 	memset(&plan, 0, sizeof(_SPI_plan));
 	plan.magic = _SPI_PLAN_MAGIC;
-	plan.cursor_options = 0;
+	plan.cursor_options = CURSOR_OPT_PARALLEL_OK;
 
 	_SPI_prepare_oneshot_plan(src, &plan);
 
@@ -458,7 +458,7 @@ SPI_execute_with_args(const char *src,
 
 	memset(&plan, 0, sizeof(_SPI_plan));
 	plan.magic = _SPI_PLAN_MAGIC;
-	plan.cursor_options = 0;
+	plan.cursor_options = CURSOR_OPT_PARALLEL_OK;
 	plan.nargs = nargs;
 	plan.argtypes = argtypes;
 	plan.parserSetup = NULL;
diff --git a/src/pl/plpgsql/src/pl_exec.c b/src/pl/plpgsql/src/pl_exec.c
index 49a4e622ff..86b8c41415 100644
--- a/src/pl/plpgsql/src/pl_exec.c
+++ b/src/pl/plpgsql/src/pl_exec.c
@@ -3031,7 +3031,7 @@ exec_stmt_return_query(PLpgSQL_execstate *estate,
 		Assert(stmt->dynquery != NULL);
 		portal = exec_dynquery_with_params(estate, stmt->dynquery,
 										   stmt->params, NULL,
-										   CURSOR_OPT_PARALLEL_OK);
+										   0);
 	}
 
 	/* Use eval_mcontext for tuple conversion work */
@@ -3627,7 +3627,12 @@ exec_stmt_execsql(PLpgSQL_execstate *estate,
 	{
 		ListCell   *l;
 
-		exec_prepare_plan(estate, expr, 0);
+		/* Allow parallelism if the function is not trigger type. */
+		if (estate->func->fn_is_trigger == PLPGSQL_NOT_TRIGGER)
+			exec_prepare_plan(estate, expr, CURSOR_OPT_PARALLEL_OK);
+		else
+			exec_prepare_plan(estate, expr, 0);
+
 		stmt->mod_stmt = false;
 		foreach(l, SPI_plan_get_plan_sources(expr->plan))
 		{
@@ -5174,7 +5179,7 @@ exec_eval_expr(PLpgSQL_execstate *estate,
 	 * If first time through, create a plan for this expression.
 	 */
 	if (expr->plan == NULL)
-		exec_prepare_plan(estate, expr, 0);
+		exec_prepare_plan(estate, expr, CURSOR_OPT_PARALLEL_OK);
 
 	/*
 	 * If this is a simple expression, bypass SPI and use the executor
@@ -5185,9 +5190,14 @@ exec_eval_expr(PLpgSQL_execstate *estate,
 		return result;
 
 	/*
-	 * Else do it the hard way via exec_run_select
+	 * Else do it the hard way via exec_run_select. Enable parallelism if
+	 * function is not trigger type.
 	 */
-	rc = exec_run_select(estate, expr, 2, NULL, false);
+	if (estate->func->fn_is_trigger == PLPGSQL_NOT_TRIGGER)
+		rc = exec_run_select(estate, expr, 2, NULL, true);
+	else
+		rc = exec_run_select(estate, expr, 2, NULL, false);
+
 	if (rc != SPI_OK_SELECT)
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
