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 1oHHUi-0004bz-UU for pgsql-hackers@arkaria.postgresql.org; Fri, 29 Jul 2022 04:21:01 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1oHHUg-0001yd-E1 for pgsql-hackers@arkaria.postgresql.org; Fri, 29 Jul 2022 04:20:58 +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 1oHHUg-0001xM-2g for pgsql-hackers@lists.postgresql.org; Fri, 29 Jul 2022 04:20:58 +0000 Received: from mail-pg1-x532.google.com ([2607:f8b0:4864:20::532]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1oHHUd-0002he-Kr for pgsql-hackers@postgresql.org; Fri, 29 Jul 2022 04:20:57 +0000 Received: by mail-pg1-x532.google.com with SMTP id l193so2714437pge.9 for ; Thu, 28 Jul 2022 21:20:55 -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=yDV1jnwlXpN3cnguVQeBqXZECLnFkgDbbBuygUaCi+w=; b=IdnLBzCCvfskhd2c2C4YBCcnyKxLiLNanSKfvklmZicIcZTVe7JHMgmZaFHXZSBTfO /rQkmYXfD8AkGGu9rgjm+4Q0X3RyxM7xjtxg7Hz4eg3ihvSpyDW8qn/Vnik+9h38Jq9e RDDH/Wbe8bmkJ+ZI+7NeF/gz8anUmZgICaHDG4WBlUhO88nWJZI1NCs4nWkl89IY3baY be6yXP2UjW6RbajweoGkEroP9wP9zzg4O8bdOLaF3rEtFBj7LcecZ4phYbvFQPTPHUFS 4MyzStJvPpU3J9oX/1gSMz2CrlZrzFCIMuD/0uXIzjNHCnPPrWzrHx6qh9/JPtgoVytI CruA== 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=yDV1jnwlXpN3cnguVQeBqXZECLnFkgDbbBuygUaCi+w=; b=Hvg5zidg1aH5vSsWvsMzonqbE6XISm6jjsDWYKI9TyUAXNEh9lbe61uxsZup47zDSs 0kp74VVaS8+rq42g7fn98F4o6AHJ7+hBrQU6MTaNryme8Xpq52omIukKXgemODpmYX8+ jG8/lJAF0nQy6YOYejx+bQAVF3oOC9dsFhzaeIW3W2M/FJDJZniThNPpyFRq1lj0MfF/ usBZ7e0w2CZ9V/Pb9XIuraU6yj1WhxM3VvUCRbxyHcOjn31yf2oFGyYF8rjWlptyQSpk REVp9Ogqo3dQ22Cah25NXUnERrg/WbZWc0Vqey/TC8RIyC8vSqzeAmEX9928hZAlAPMb Q95Q== X-Gm-Message-State: AJIora8TcKcPqohBHzbsKmzxNiy+n+aWFLyIM4BdDnzLK+hji4Tzw+gu 9bvcJnqZV/4HeMLoPyV1bPKEXXNjkBABS6fT6ow= X-Google-Smtp-Source: AGRyM1vkywSO+CNTwaj8z4e+9SV15zjPTvwpbldW/ciOPGyAaXg33/gFcjrc4gKlAyiqDC37yUfM4nKaYRab8VwPHVo= X-Received: by 2002:a63:5fcf:0:b0:412:a708:d660 with SMTP id t198-20020a635fcf000000b00412a708d660mr1476607pgb.622.1659068454327; Thu, 28 Jul 2022 21:20:54 -0700 (PDT) MIME-Version: 1.0 References: <215356.1647286703@sss.pgh.pa.us> In-Reply-To: From: Amit Langote Date: Fri, 29 Jul 2022 13:20:37 +0900 Message-ID: Subject: Re: generic plans and "initial" pruning To: Robert Haas Cc: Jacob Champion , Zhihong Yu , 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 Thu, Jul 28, 2022 at 1:27 AM Robert Haas wrote: > On Tue, Jul 26, 2022 at 11:01 PM Amit Langote wrote: > > Needed to be rebased again, over 2d04277121f this time. Thanks for looking. > 0001 adds es_part_prune_result but does not use it, so maybe the > introduction of that field should be deferred until it's needed for > something. Oops, looks like a mistake when breaking the patch. Will move that bit to 0002. > I wonder whether it's really necessary to added the PartitionPruneInfo > objects to a list in PlannerInfo first and then roll them up into > PlannerGlobal later. I know we do that for range table entries, but > I've never quite understood why we do it that way instead of creating > a flat range table in PlannerGlobal from the start. And so by > extension I wonder whether this table couldn't be flat from the start > also. Tom may want to correct me but my understanding of why the planner waits till the end of planning to start populating the PlannerGlobal range table is that it is not until then that we know which subqueries will be scanned by the final plan tree, so also whose range table entries will be included in the range table passed to the executor. I can see that subquery pull-up causes a pulled-up subquery's range table entries to be added into the parent's query's and all its nodes changed using OffsetVarNodes() to refer to the new RT indexes. But for subqueries that are not pulled up, their subplans' nodes (present in PlannerGlboal.subplans) would still refer to the original RT indexes (per range table in the corresponding PlannerGlobal.subroot), which must be fixed and the end of planning is the time to do so. Or maybe that could be done when build_subplan() creates a subplan and adds it to PlannerGlobal.subplans, but for some reason it's not? -- Thanks, Amit Langote EDB: http://www.enterprisedb.com