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 1rcIN9-0021tA-5c for pgsql-hackers@arkaria.postgresql.org; Tue, 20 Feb 2024 05:08:51 +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 1rcIN7-001OcW-Hd for pgsql-hackers@arkaria.postgresql.org; Tue, 20 Feb 2024 05:08:49 +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 1rcIN7-001OcJ-8M for pgsql-hackers@lists.postgresql.org; Tue, 20 Feb 2024 05:08:49 +0000 Received: from mail-ua1-x92a.google.com ([2607:f8b0:4864:20::92a]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1rcIN2-0086W4-3R for pgsql-hackers@postgresql.org; Tue, 20 Feb 2024 05:08:48 +0000 Received: by mail-ua1-x92a.google.com with SMTP id a1e0cc1a2514c-7d6a772e08dso1714417241.2 for ; Mon, 19 Feb 2024 21:08:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708405722; x=1709010522; darn=postgresql.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=z4Lmw70YKK83CZvXX4DEPLrtqNjc3CVinw1chNntR9M=; b=je8JcgLh6k8J30Y6BFeWO0Pijq2OTqTOFKxuYCPAHSnfkhk4/nxASBvIRsaZNALjBI RTVTNJvYYoB/Uq7o91z1hZC7oKL6lWiIpjDVo3mWzk0DCAbPAsl9pLfVnrrFjSr4nJV9 RLclk1sF+ploosfiZJ1ugYHEzpd09a06EGvmZtA7QGbHFYbebTnDv9VVwoACEAL4LCS+ UbWIgbGp25IofJh+WbygUTeQZpnY7gnSIqOuim9I+ymoGtIFpFUS9jmVkukaA2oeNHKN 5j4Cg7UWjgzYZO9RwFk8ws6N/1JdXv2vqVNM9SJm/lnYLXw6M94eMacz0M4iFAm6zIQS xkOw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708405722; x=1709010522; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=z4Lmw70YKK83CZvXX4DEPLrtqNjc3CVinw1chNntR9M=; b=tVkNJkMWFYg5v4Ilo6a7tzRM3Aw+YmBUutgVTK/riaIy5WqUeJ8Da/6GDv3VKZmRaM J83XzMVpeLciLhajeVii9np2GtwvUTO1hpRPjFN0ryEUoTrdi4Zm1/cSBvzNkv7Jds7k qZE6ftWLFeamGzPx/Vc4dWLye7tDip9RVsoMtgjAye+LT36dI3r7zhYwJmlc3xOQjads DLB6aqkOorKCBxWfZAzB1yLAWz0cewVsfbpEUJ9L6loPiTzHYqeGR0lCVacA4FHhHh+m chg3/jBlaOzRxi0EllkQyuk5qkjWGTw6MLKnPiGYVLMSX+z6DRsD7QfgXKGxT2TDqUGg EEhg== X-Forwarded-Encrypted: i=1; AJvYcCWnl+Fb2jFyvjuCjX8A65PKZDJ2SDr3lMi4lX/ZARyYmR2iLzHE0+Y3AamZIGowfVXbqSZy5d7jLd4LNqG8162Ot1fp7QF86nU8HJFR X-Gm-Message-State: AOJu0YyOUd5XT4td0BLYjDW2A5PfGknDJnGJ9kISoL+18gOHu8DTz8Zg 2PmVQeaFL4x9rIYcbhtGkmDlxUB0mb5+tiyY7CbQBd26pQLYml3WYWRrzP9CpFXsyB0jaf4LMqS UVoIUI/sruy32VpETnweIWBd0RH4= X-Google-Smtp-Source: AGHT+IHbabY+RTpJ/zPH04nR/4bbLfwfm04NxOsK0g4UztscXLL6zybEtzbrrSGg9RvAi8zU4zonXQevxBPraGyGabM= X-Received: by 2002:a05:6102:3708:b0:470:5c4a:86ad with SMTP id s8-20020a056102370800b004705c4a86admr3996202vst.22.1708405722270; Mon, 19 Feb 2024 21:08:42 -0800 (PST) MIME-Version: 1.0 References: <182fbad0-f3f6-4692-8fc4-778378e1db01@postgrespro.ru> In-Reply-To: From: Ashutosh Bapat Date: Tue, 20 Feb 2024 10:38:31 +0530 Message-ID: Subject: Re: Memory consumed by paths during partitionwise join planning To: Andrei Lepikhov Cc: David Rowley , pgsql-hackers Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Tue, Feb 20, 2024 at 8:19=E2=80=AFAM Andrei Lepikhov wrote: > > On 19/2/2024 19:25, Ashutosh Bapat wrote: > > On Fri, Feb 16, 2024 at 8:42=E2=80=AFAM Andrei Lepikhov > > wrote: > >> Live example: right now, I am working on the code like MSSQL has - a > >> combination of NestLoop and HashJoin paths and switching between them = in > >> real-time. It requires both paths in the path list at the moment when > >> extensions are coming. Even if one of them isn't referenced from the > >> upper pathlist, it may still be helpful for the extension. > > > > There is no guarantee that every path presented to add_path will be > > preserved. Suboptimal paths are freed as and when add_path discovers > > that they are suboptimal. So I don't think an extension can rely on > > existence of a path. But having a refcount makes it easy to preserve > > the required paths by referencing them. > I don't insist, just provide my use case. It would be ideal if you would > provide some external routines for extensions that allow for sticking > the path in pathlist even when it has terrible cost estimation. With refcounts you can reference it and store it somewhere other than pathlist. The path won't be lost until it is dereferrenced. RelOptInfo::Pathlist is for optimal paths. > > > >> > >> > > IIUC, you are suggesting that instead of planning each > > partition/partitionwise join, we only create paths with the strategies > > which were found to be optimal with previous partitions. That's a good > > heuristic but it won't work if partition properties - statistics, > > indexes etc. differ between groups of partitions. > Sure, but the "Symmetry" strategy assumes that on the scope of a > thousand partitions, especially with parallel append involved, it > doesn't cause sensible performance degradation if we find a bit > suboptimal path in a small subset of partitions. Does it make sense? > As I see, when people use 10-100 partitions for the table, they usually > strive to keep indexes symmetrical for all partitions. > I agree that we need something like that. In order to do that, we need machinery to prove that all partitions have similar properties. Once that is proved, we can skip creating paths for similar partitions. But that's out of scope of this work and complements it. --=20 Best Wishes, Ashutosh Bapat