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 1nTpeP-00011v-7Q for pgsql-hackers@arkaria.postgresql.org; Mon, 14 Mar 2022 18:42:37 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nTpeN-0001Pj-Si for pgsql-hackers@arkaria.postgresql.org; Mon, 14 Mar 2022 18:42:35 +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 1nTpeN-0001Pa-HZ for pgsql-hackers@lists.postgresql.org; Mon, 14 Mar 2022 18:42:35 +0000 Received: from mail-lj1-x22c.google.com ([2a00:1450:4864:20::22c]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1nTpeK-0003s7-Dr for pgsql-hackers@postgresql.org; Mon, 14 Mar 2022 18:42:34 +0000 Received: by mail-lj1-x22c.google.com with SMTP id z26so23257850lji.8 for ; Mon, 14 Mar 2022 11:42:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=cvhn20b7pU5Yp7QNnj990QWHBKOE7YXbgmtlR/mK2ro=; b=Y1oj8aWeEtqbUooSlesGCngyegOmVqTY1ZY0mdzedQA5uh7iotM+CYwJA+g3IjwErh MpbjL2IUpXhp0EFUeUW3Qi7h2M38SGAi9Vp1rgIvFpKsnD4xtRk0TtXC1lJE39WeCH9/ 2GvSZgbNQ0IFSb367QyXYmeCTbewiNkKMDy36kLiC5oH/HozrpleDYPmLEJso6VMZmkz 9xIYamZUAYZkxRh8Hvl/rbBK6mG/tPdAUm1DdLliLDvbLNdcbIYHr9FOjrU5NZ0NCG3V MVokAJgWsY14TWkKKglif7ixwBUcIiVLk5aiHACDBKluaHlxw2HZiuNV2/dZn83UFA7S LtcQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=cvhn20b7pU5Yp7QNnj990QWHBKOE7YXbgmtlR/mK2ro=; b=Dz1aSzDzrWBs4Cn06vb2dK5eQ/ocdW17iLnWFqcI1+rNl/HCOEUv6TOw41D31WyqNT OAdy9Z6A462VGuu5CURij72BrvD7gHmXjcs/sOIzUH9/shwTEDKVrNosV/DQfhU+KmKv Kfrz1Tnzx1BR62aZK3Mv9LbzWAfoUaqETH95vdUSB5f1AAP5gdE6NqoHKQVHgIm2jsno 8bY0eQYGkVCvpm1Nwst+4yxXF3eXEoM2JnrTvbQfR2BMhnw1a59Or/l7VD96iiDYxivr HPZKWacP3od988D5lPqKGlUqrnfHNnI+WNrLb8qlUirV9Jm8YBqQUFqKcYpXtw5fkxI2 seUg== X-Gm-Message-State: AOAM530MJh1QrGhWUHvViOdFyEmaxBzsNw3GPLvIaw9K3prSKK79vfbh P/pjU1uNl2JKjmHCZ6djYgb0321skvE2UgvziXEdCltqq1U= X-Google-Smtp-Source: ABdhPJwMnnvxMn0vLifAzKk8wzi1pmfBOSizwqCTBJL7DtHlDTBvYzw7ne4jlFr0vBmRfSb9RftQb/GH+vm2vCf+zU0= X-Received: by 2002:a2e:5cc:0:b0:249:13bc:1685 with SMTP id 195-20020a2e05cc000000b0024913bc1685mr13000715ljf.254.1647283350851; Mon, 14 Mar 2022 11:42:30 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Robert Haas Date: Mon, 14 Mar 2022 14:42:19 -0400 Message-ID: Subject: Re: generic plans and "initial" pruning To: Amit Langote Cc: PostgreSQL-development , "David Rowley *EXTERN*" , Tom Lane 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, Mar 11, 2022 at 9:35 AM Amit Langote wrote: > Attached is v5, now broken into 3 patches: > > 0001: Some refactoring of runtime pruning code > 0002: Add a plan_tree_walker > 0003: Teach AcquireExecutorLocks to skip locking pruned relations So is any other committer planning to look at this? Tom, perhaps? David? This strikes me as important work, and I don't mind going through and trying to do some detailed review, but (A) I am not the person most familiar with the code being modified here and (B) there are some important theoretical questions about the approach that we might want to try to cover before we get down into the details. In my opinion, the most important theoretical issue here is around reuse of plans that are no longer entirely valid, but the parts that are no longer valid are certain to be pruned. If, because we know that some parameter has some particular value, we skip locking a bunch of partitions, then when we're executing the plan, those partitions need not exist any more -- or they could have different indexes, be detached from the partitioning hierarchy and subsequently altered, whatever. That seems fine to me provided that all of our code (and any third-party code) is careful not to rely on the portion of the plan that we've pruned away, and doesn't assume that (for example) we can still fetch the name of an index whose OID appears in there someplace. I cannot think of a hazard where the fact that the part of a plan is no longer valid because some DDL has been executed "infects" the remainder of the plan. As long as we lock the partitioned tables named in the plan and their descendents down to the level just above the one at which something is pruned, and are careful, I think we should be OK. It would be nice to know if someone has a fundamentally different view of the hazards here, though. Just to state my position here clearly, I would be more than happy if somebody else plans to pick this up and try to get some or all of it committed, and will cheerfully defer to such person in the event that they have that plan. If, however, no such person exists, I may try my hand at that myself. Thanks, -- Robert Haas EDB: http://www.enterprisedb.com