Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tLftO-00GI93-Ek for pgsql-hackers@arkaria.postgresql.org; Thu, 12 Dec 2024 09:53:58 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1tLfsM-009WaU-CG for pgsql-hackers@arkaria.postgresql.org; Thu, 12 Dec 2024 09:52:55 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tLfsM-009WaL-16 for pgsql-hackers@lists.postgresql.org; Thu, 12 Dec 2024 09:52:55 +0000 Received: from mail-ed1-x52c.google.com ([2a00:1450:4864:20::52c]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1tLfsF-002RA5-Uh for pgsql-hackers@postgresql.org; Thu, 12 Dec 2024 09:52:54 +0000 Received: by mail-ed1-x52c.google.com with SMTP id 4fb4d7f45d1cf-5d3ea065b79so591663a12.3 for ; Thu, 12 Dec 2024 01:52:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cybertec.at; s=google; t=1733997167; x=1734601967; darn=postgresql.org; h=message-id:date:mime-version:subject:to:from:from:to:cc:subject :date:message-id:reply-to; bh=CS3VCDluu52QTVlePlUz96gUM/T5h9x6ZGFO6szTQGs=; b=SUd75MSeoOlHJWIS3rcGW0QSAVGMhC5KnOQstR15DKq8eOtwwTYGHEpC+RcCb6Ovoa s5BO7yqBo4BLMec9cv+QcgegxNMBhmA5n/H5Z6PfdG6/GXzu3wq8ICnTfBAR5PYVd+/a F8BIsbw3YG27VIdfdi/Q1OEEc2VKQBN+hmKzhVU0aT5BOFK4j0xxYl2aGlND382r27bO da+VGbk/CIySEnO0Wcg0iaSW3dG1gIqqsMYiuiD+glxv69RbahheDE2UmV5alePpIpZM W5QnrU/3dgav+MvR2oOeaAlqBE4MmjVoOGFv47BmMGu5HGqgwSf+TeQi/psm883s83v7 L9vg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733997167; x=1734601967; h=message-id:date:mime-version:subject:to:from:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=CS3VCDluu52QTVlePlUz96gUM/T5h9x6ZGFO6szTQGs=; b=RR4k7DPFlo8O8VE6EE+7YU7wo/GazcIlZrnYkhkEyccCNPtjsGglzUeuqQPXfIkgIs Y9yHFWF73+/zKUJ4q3/C2UltTQGgAqzI62ZQjm1ocHWH8lfSdToHTAdAxSwK89MKlQBR PyN/Ak6upsOCq+Qoml2k65pt1ZKugSLS0QEOC4Fmk1Xun2f8ZSGJyum+foZ6U9Hx4EJl Xxn3FAGie0d3Gabl/koMcPp5SHFTuT4qZT0ldZfWcbIuAkEcOVmbleHw1fr/rWVvr1sZ sGRhbssqcO0ZmjcwlCeQVccbH/ZOU94EMNZf7+tHKomqHiuXe89UZIA8JhjVrR6r1Z+9 dvCw== X-Gm-Message-State: AOJu0YwFk/J2d74SW5YMtnUQRT9s+4NAXP8zif5JacjlJGySPzt5wcQv hPCcwCcbSsagFLi7UEiquaxwWgq+l1NRv4Hju4+AtXzufqIZvOjOsyp6myeM7GkaoSfDXJoUMLJ s X-Gm-Gg: ASbGncvNz8RStl5+OaU0Cr4Y2w9y47qezjBaV8zFSL7X8fwjjDux5aq6rrW9P7D8C5P g/bjslDWuO9SDtx1XM+uJzCOY41xc137+odWLSRMTBLL2ZSmb5nIt2MO4exJxXF/RdMPuLOPvHf ELg+4ewwbuBVwEKVMC63llefe4PHLC+LAVSUZIkoCZGQ1bBUD+PuVMESNIZvpo8GEjXeWLCAO3R yz4GpV9ljHvgWTuvxr0g8M9aFHZ8pusqALhU1HpOP7tUwRDz/XGpwr9Dknx X-Google-Smtp-Source: AGHT+IFiIJ08zWuEHppLyMRtt5U9CzxiNZtYNEQ5iJlQzN1SaXWS4+rXpwKqEDTp8rPgbFFvi2u6oQ== X-Received: by 2002:a05:6402:5192:b0:5d3:ba42:e9fe with SMTP id 4fb4d7f45d1cf-5d4edce043amr407796a12.12.1733997167198; Thu, 12 Dec 2024 01:52:47 -0800 (PST) Received: from antos (109-81-174-36.rct.o2.cz. [109.81.174.36]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5d3ee6ddf5dsm6720372a12.86.2024.12.12.01.52.46 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Dec 2024 01:52:46 -0800 (PST) From: Antonin Houska To: pgsql-hackers@postgresql.org Subject: single_copy not needed in GatherPath X-Mailer: MH-E 8.6+git; nmh 1.8; GNU Emacs 28.3 MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Date: Thu, 12 Dec 2024 10:52:46 +0100 Message-ID: <39089.1733997166@antos> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --=-=-= Content-Type: text/plain I was curious when create_gather_path() sets single_copy, but could not find any place in the tree where a path with num_workers==0 is added to partial_pathlist. This patch removes the field. -- Antonin Houska Web: https://www.cybertec-postgresql.com --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-Remove-the-single_copy-field-from-GatherPath.patch From 3f434cfb8b7eb70049650d1f324fe8cbaf1267cb Mon Sep 17 00:00:00 2001 From: Antonin Houska Date: Thu, 12 Dec 2024 10:22:40 +0100 Subject: [PATCH] Remove the single_copy field from GatherPath. While single_copy is useful in the Gather plan, it's set regardless the value in GatherPath: standard_planner() sets the flag on a new instance of Gather, for which there is no corresponding GatherPath. Furthermore, the field is never set in GatherPath anyway because parial paths always have parallel_workers > 0. --- src/backend/optimizer/plan/createplan.c | 6 ++---- src/backend/optimizer/util/pathnode.c | 9 +-------- src/include/nodes/pathnodes.h | 4 +--- 3 files changed, 4 insertions(+), 15 deletions(-) diff --git a/src/backend/optimizer/plan/createplan.c b/src/backend/optimizer/plan/createplan.c index 178c572b02..dfceb3e615 100644 --- a/src/backend/optimizer/plan/createplan.c +++ b/src/backend/optimizer/plan/createplan.c @@ -300,7 +300,7 @@ static Unique *make_unique_from_sortclauses(Plan *lefttree, List *distinctList); static Unique *make_unique_from_pathkeys(Plan *lefttree, List *pathkeys, int numCols); static Gather *make_gather(List *qptlist, List *qpqual, - int nworkers, int rescan_param, bool single_copy, Plan *subplan); + int nworkers, int rescan_param, Plan *subplan); static SetOp *make_setop(SetOpCmd cmd, SetOpStrategy strategy, Plan *lefttree, List *distinctList, AttrNumber flagColIdx, int firstFlag, long numGroups); @@ -1940,7 +1940,6 @@ create_gather_plan(PlannerInfo *root, GatherPath *best_path) NIL, best_path->num_workers, assign_special_exec_param(root), - best_path->single_copy, subplan); copy_generic_path_info(&gather_plan->plan, &best_path->path); @@ -6930,7 +6929,6 @@ make_gather(List *qptlist, List *qpqual, int nworkers, int rescan_param, - bool single_copy, Plan *subplan) { Gather *node = makeNode(Gather); @@ -6942,7 +6940,7 @@ make_gather(List *qptlist, plan->righttree = NULL; node->num_workers = nworkers; node->rescan_param = rescan_param; - node->single_copy = single_copy; + node->single_copy = false; node->invisible = false; node->initParam = NULL; diff --git a/src/backend/optimizer/util/pathnode.c b/src/backend/optimizer/util/pathnode.c index fc97bf6ee2..f03240c77a 100644 --- a/src/backend/optimizer/util/pathnode.c +++ b/src/backend/optimizer/util/pathnode.c @@ -2059,15 +2059,8 @@ create_gather_path(PlannerInfo *root, RelOptInfo *rel, Path *subpath, pathnode->path.pathkeys = NIL; /* Gather has unordered result */ pathnode->subpath = subpath; + Assert(subpath->parallel_workers > 0); pathnode->num_workers = subpath->parallel_workers; - pathnode->single_copy = false; - - if (pathnode->num_workers == 0) - { - pathnode->path.pathkeys = subpath->pathkeys; - pathnode->num_workers = 1; - pathnode->single_copy = true; - } cost_gather(pathnode, root, rel, pathnode->path.param_info, rows); diff --git a/src/include/nodes/pathnodes.h b/src/include/nodes/pathnodes.h index 0759e00e96..0c7df1e6fa 100644 --- a/src/include/nodes/pathnodes.h +++ b/src/include/nodes/pathnodes.h @@ -2045,14 +2045,12 @@ typedef struct UniquePath /* * GatherPath runs several copies of a plan in parallel and collects the - * results. The parallel leader may also execute the plan, unless the - * single_copy flag is set. + * results. */ typedef struct GatherPath { Path path; Path *subpath; /* path for each worker */ - bool single_copy; /* don't execute path more than once */ int num_workers; /* number of workers sought to help */ } GatherPath; -- 2.45.2 --=-=-=--