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 1nJMqJ-0005gt-9q for pgsql-hackers@arkaria.postgresql.org; Sun, 13 Feb 2022 21:55:39 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nJMqH-0004Ki-TJ for pgsql-hackers@arkaria.postgresql.org; Sun, 13 Feb 2022 21:55:37 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nJMqH-0004KY-IY for pgsql-hackers@lists.postgresql.org; Sun, 13 Feb 2022 21:55:37 +0000 Received: from mail-pl1-x636.google.com ([2607:f8b0:4864:20::636]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1nJMqC-0002fS-Cp for pgsql-hackers@postgresql.org; Sun, 13 Feb 2022 21:55:37 +0000 Received: by mail-pl1-x636.google.com with SMTP id x4so9099543plb.4 for ; Sun, 13 Feb 2022 13:55:31 -0800 (PST) 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=w92wZ0idKkkIIKltvtZdZECg7wjgGvSaw4a5D+aknCg=; b=R80egXzyvLvCZss5ZqyCrdL5KGn3nM2ZkdDJf06lctSwupkgjuqarA/XQkhMfWLHii O6YNox1t0V+aIXV2mDnH3RYEP79TE/28C9tWwTUz1QDyvHMSpRmrnqz3T7BCcz0248VZ zOYh6zUEf0UPqDjIwVQO1LnYfLYX+s1zorHo3TJFGaMuxikRTp9Pl28IGNbwNDbKOq+4 73HW0GkI7YFZQMS+ix8hxya4WSQhryXfEyaBGEh1N69erM8NS1s2wL3a87LtJz9kKeoQ HSITpNTACajnTd+BuOBjJuhyo8Ofv9P3IKjxaoY/myIqz9weO58sd4AvYA9BpFNkRXGB 4VTA== 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=w92wZ0idKkkIIKltvtZdZECg7wjgGvSaw4a5D+aknCg=; b=38sQnZkqQ1LK9APzey+Ml/IRKmEKVgZGQj0tjRGRHqSdtc11Leq0iMN7lK8Av3pa0u eMvtjna+0V3Eh5qZY0O1s0A1fwuImZH1umufXQjme2HNDUZR7T8oCxvv2g1zvV6R+Rxm YxpkaSc0NPvFfW6j73dIxqy/qPDZs/dDJY0GFvs81Uq1JuJe6d9Q65/grKeffe9xjWF9 n5oVYco4PwRKA/ZB8fZiyNqGxkvDn1TM6VDsIvis7wfNQM5LW3+Two6BrxViPRzh8WTJ ybbcwtnvVhkCnkX4pvrcZa/HaBfNkiFToZpTrV4mIVEbFt4W4BIIYJjy8vedpQYPG+W/ PfbQ== X-Gm-Message-State: AOAM530rnZ0OZKJkatiuj8at2D2LCyMIpq38FrJnv/QrgFuXI/5gLkGV gkYHHn3YIrsdpVpAAKyfCFiV7gET91C0ibgaF8Y= X-Google-Smtp-Source: ABdhPJykYqiTXmxq9hAvc51xbibNrFZsuHIuJSmOInlc8dHIYOx41ajC/XbOU88RCzB8/WmELj6XfacjZgc7oV3xx9s= X-Received: by 2002:a17:903:22ca:: with SMTP id y10mr11432372plg.127.1644789330052; Sun, 13 Feb 2022 13:55:30 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: David Rowley Date: Mon, 14 Feb 2022 10:55:16 +1300 Message-ID: Subject: Re: generic plans and "initial" pruning To: Robert Haas Cc: Amit Langote , 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 (just catching up on this thread) On Thu, 13 Jan 2022 at 07:20, Robert Haas wrote: > Yeah. I don't think it's only non-core code we need to worry about > either. What if I just do EXPLAIN ANALYZE on a prepared query that > ends up pruning away some stuff? IIRC, the pruned subplans are not > shown, so we might escape disaster here, but FWIW if I'd committed > that code I would have pushed hard for showing those and saying "(not > executed)" .... so it's not too crazy to imagine a world in which > things work that way. FWIW, that would remove the whole point in init run-time pruning. The reason I made two phases of run-time pruning was so that we could get away from having the init plan overhead of nodes we'll never need to scan. If we wanted to show the (never executed) scans in EXPLAIN then we'd need to do the init plan part and allocate all that memory needlessly. Imagine a hash partitioned table on "id" with 1000 partitions. The user does: PREPARE q1 (INT) AS SELECT * FROM parttab WHERE id = $1; EXECUTE q1(123); Assuming a generic plan, if we didn't have init pruning then we have to build a plan containing the scans for all 1000 partitions. There's significant overhead to that compared to just locking the partitions, and initialising 1 scan. If it worked this way then we'd be even further from Amit's goal of reducing the overhead of starting plan with run-time pruning nodes. I understood at the time it was just the EXPLAIN output that you had concerns with. I thought that was just around the lack of any display of the condition we used for pruning. David