Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1p3b99-0004Qj-9M for pgsql-hackers@arkaria.postgresql.org; Fri, 09 Dec 2022 11:02:27 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1p3b98-0006gP-5D for pgsql-hackers@arkaria.postgresql.org; Fri, 09 Dec 2022 11:02:26 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1p3b97-0006ey-Py for pgsql-hackers@lists.postgresql.org; Fri, 09 Dec 2022 11:02:25 +0000 Received: from mail-pg1-x531.google.com ([2607:f8b0:4864:20::531]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1p3b95-00016u-L0 for pgsql-hackers@postgresql.org; Fri, 09 Dec 2022 11:02:24 +0000 Received: by mail-pg1-x531.google.com with SMTP id w37so3304604pga.5 for ; Fri, 09 Dec 2022 03:02:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=XHDj6J/5MRbjUsO91s4rYUWoirnUKfLJ1uB0ODJyx2w=; b=MXAIywOK7FIOarb1tLUa+hZjHIAdhLd7Brjyr/Pp9OF5veRJo0ak0u+idlPQEg3HbD VFv+/BHXfMO0J0ZTQUt4074sMwXb8SDZfjVXzBP0vyhgB4B/vwPA3avSJ0nG+uHwf8Ce lQjuZmnFeTbebrMHLQb0I/7Khx6ru1tE+krdjCVBTCpa5IhPaEVYpQL6YCNNi5U2vxMJ kKkIGCFgnnDSubrDeDq+dEXhIfyLLYCIIXV2XH3Q6cDd3uk/V2cWZRHsdvPD6AwIu6D6 lW8PCoVsJYe3KLBsgXqZOQg0cHoSBG0tHjxzC9XZDDBYvN7QBkLXtp1KdePAESWjiimc Dztw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=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=XHDj6J/5MRbjUsO91s4rYUWoirnUKfLJ1uB0ODJyx2w=; b=YbaGE746mutLSCHAyY3TJ7ZsuGHs8CmBUXLkBZWFcgVCAE9VNA1jwzZ24Ja9XuHe7e 0j5aka50kRVLUJhvUWTIYsecpzcaB3ZppKeNcghUIN40FRsF34yyR48yHVyXa46QnyKf 8+wqgZTKdiKLvTvOLGZNHg24FZuJTtveLHDoOblv4T/wkS5mx7DXtJqsQgoFYDVxdLdu 4HcLE+T2vWFcXSRZzDnxnR2HanY8+wYUziHN46QE2NMn+zUzC6IUDwGIipNIg9tkHjTK wxo7o3FTolfI/T0UlqzvjjsrA95ZoMe9mN/K/a7ZGMh7vcCe0P0h8oAOeVYdZaDxcTJ1 tCyA== X-Gm-Message-State: ANoB5pmtrH0+IZ6OX1LYC646PPk0oqg3HmN+8hnNN/63RI05UV0dc+BK 4tRADM2tHjmJigRoXw6tbQEtueigmJ/68RpVQ/k= X-Google-Smtp-Source: AA0mqf7PrcYnsoeYFqh0rZ1KSPKbPws8jFD9ze+nr9xEVUQ6xdyVUxADN6jIc+2CI1VtWXBHJ8n/sKGIa+KdfMbjpgA= X-Received: by 2002:a05:6a00:1696:b0:571:2b7c:6693 with SMTP id k22-20020a056a00169600b005712b7c6693mr79461075pfc.48.1670583742423; Fri, 09 Dec 2022 03:02:22 -0800 (PST) MIME-Version: 1.0 References: <20221209104947.dkon6xtiaffainue@alvherre.pgsql> In-Reply-To: <20221209104947.dkon6xtiaffainue@alvherre.pgsql> From: Amit Langote Date: Fri, 9 Dec 2022 20:02:05 +0900 Message-ID: Subject: Re: generic plans and "initial" pruning To: Alvaro Herrera Cc: Robert Haas , Jacob Champion , David Rowley , Tom Lane , PostgreSQL-development Content-Type: text/plain; charset="UTF-8" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Fri, Dec 9, 2022 at 7:49 PM Alvaro Herrera wrote: > On 2022-Dec-09, Amit Langote wrote: > > On Fri, Dec 9, 2022 at 6:52 PM Alvaro Herrera wrote: > > > Remind me again why is part_prune_results_list not part of struct > > > CachedPlan then? I tried to understand that based on comments upthread, > > > but I was unable to find anything. > > > > > (My first reaction to your above comment was "well, rename GetCachedPlan > > > then, maybe to GetRunnablePlan", but then I'm wondering if CachedPlan is > > > in any way a structure that must be "immutable" in the way parser output > > > is. Looking at the comment at the top of plancache.c it appears to me > > > that it isn't, but maybe I'm missing something.) > > > > CachedPlan *is* supposed to be read-only per the comment above > > CachedPlanSource definition: > > > > * ...If we are using a generic > > * cached plan then it is meant to be re-used across multiple executions, so > > * callers must always treat CachedPlans as read-only. > > I read that as implying that the part_prune_results_list must remain > intact as long as no invalidations occur. Does part_prune_result_list > really change as a result of something other than a sinval event? > Keep in mind that if a sinval message that touches one of the relations > in the plan arrives, then we'll discard it and generate it afresh. I > don't see that the part_prune_results_list would change otherwise, but > maybe I misunderstand? Pruning will be done afresh on every fetch of a given cached plan when CheckCachedPlan() is called on it, so the part_prune_results_list part will be discarded and rebuilt as many times as the plan is executed. You'll find a description around CachedPlanSavePartitionPruneResults() that's in v12. -- Thanks, Amit Langote EDB: http://www.enterprisedb.com