mirror of
https://github.com/postgres/postgres.git
synced 2025-11-19 13:42:17 +03:00
Revert "Enable parallel SELECT for "INSERT INTO ... SELECT ..."."
To allow inserts in parallel-mode this feature has to ensure that all the constraints, triggers, etc. are parallel-safe for the partition hierarchy which is costly and we need to find a better way to do that. Additionally, we could have used existing cached information in some cases like indexes, domains, etc. to determine the parallel-safety. List of commits reverted, in reverse chronological order:ed62d3737cDoc: Update description for parallel insert reloption.c8f78b6161Add a new GUC and a reloption to enable inserts in parallel-mode.c5be48f092Improve FK trigger parallel-safety check added by05c8482f7f.e2cda3c20aFix use of relcache TriggerDesc field introduced by commit05c8482f7f.e4e87a32ccFix valgrind issue in commit05c8482f7f.05c8482f7fEnable parallel SELECT for "INSERT INTO ... SELECT ...". Discussion: https://postgr.es/m/E1lMiB9-0001c3-SY@gemulon.postgresql.org
This commit is contained in:
@@ -305,7 +305,6 @@ standard_planner(Query *parse, const char *query_string, int cursorOptions,
|
||||
glob->resultRelations = NIL;
|
||||
glob->appendRelations = NIL;
|
||||
glob->relationOids = NIL;
|
||||
glob->partitionOids = NIL;
|
||||
glob->invalItems = NIL;
|
||||
glob->paramExecTypes = NIL;
|
||||
glob->lastPHId = 0;
|
||||
@@ -317,16 +316,16 @@ standard_planner(Query *parse, const char *query_string, int cursorOptions,
|
||||
/*
|
||||
* Assess whether it's feasible to use parallel mode for this query. We
|
||||
* can't do this in a standalone backend, or if the command will try to
|
||||
* modify any data (except for Insert), or if this is a cursor operation,
|
||||
* or if GUCs are set to values that don't permit parallelism, or if
|
||||
* parallel-unsafe functions are present in the query tree.
|
||||
* modify any data, or if this is a cursor operation, or if GUCs are set
|
||||
* to values that don't permit parallelism, or if parallel-unsafe
|
||||
* functions are present in the query tree.
|
||||
*
|
||||
* (Note that we do allow CREATE TABLE AS, INSERT INTO...SELECT, SELECT
|
||||
* INTO, and CREATE MATERIALIZED VIEW to use parallel plans. However, as
|
||||
* of now, only the leader backend writes into a completely new table. In
|
||||
* the future, we can extend it to allow workers to write into the table.
|
||||
* However, to allow parallel updates and deletes, we have to solve other
|
||||
* problems, especially around combo CIDs.)
|
||||
* (Note that we do allow CREATE TABLE AS, SELECT INTO, and CREATE
|
||||
* MATERIALIZED VIEW to use parallel plans, but as of now, only the leader
|
||||
* backend writes into a completely new table. In the future, we can
|
||||
* extend it to allow workers to write into the table. However, to allow
|
||||
* parallel updates and deletes, we have to solve other problems,
|
||||
* especially around combo CIDs.)
|
||||
*
|
||||
* For now, we don't try to use parallel mode if we're running inside a
|
||||
* parallel worker. We might eventually be able to relax this
|
||||
@@ -335,14 +334,13 @@ standard_planner(Query *parse, const char *query_string, int cursorOptions,
|
||||
*/
|
||||
if ((cursorOptions & CURSOR_OPT_PARALLEL_OK) != 0 &&
|
||||
IsUnderPostmaster &&
|
||||
(parse->commandType == CMD_SELECT ||
|
||||
is_parallel_allowed_for_modify(parse)) &&
|
||||
parse->commandType == CMD_SELECT &&
|
||||
!parse->hasModifyingCTE &&
|
||||
max_parallel_workers_per_gather > 0 &&
|
||||
!IsParallelWorker())
|
||||
{
|
||||
/* all the cheap tests pass, so scan the query tree */
|
||||
glob->maxParallelHazard = max_parallel_hazard(parse, glob);
|
||||
glob->maxParallelHazard = max_parallel_hazard(parse);
|
||||
glob->parallelModeOK = (glob->maxParallelHazard != PROPARALLEL_UNSAFE);
|
||||
}
|
||||
else
|
||||
@@ -523,19 +521,6 @@ standard_planner(Query *parse, const char *query_string, int cursorOptions,
|
||||
result->rewindPlanIDs = glob->rewindPlanIDs;
|
||||
result->rowMarks = glob->finalrowmarks;
|
||||
result->relationOids = glob->relationOids;
|
||||
|
||||
/*
|
||||
* Register the Oids of parallel-safety-checked partitions as plan
|
||||
* dependencies. This is only really needed in the case of a parallel plan
|
||||
* so that if parallel-unsafe properties are subsequently defined on the
|
||||
* partitions, the cached parallel plan will be invalidated, and a
|
||||
* non-parallel plan will be generated.
|
||||
*
|
||||
* We also use this list to acquire locks on partitions before executing
|
||||
* cached plan. See AcquireExecutorLocks().
|
||||
*/
|
||||
if (glob->partitionOids != NIL && glob->parallelModeNeeded)
|
||||
result->partitionOids = glob->partitionOids;
|
||||
result->invalItems = glob->invalItems;
|
||||
result->paramExecTypes = glob->paramExecTypes;
|
||||
/* utilityStmt should be null, but we might as well copy it */
|
||||
|
||||
Reference in New Issue
Block a user