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 1tp1Dr-00H7cf-CZ for pgsql-hackers@arkaria.postgresql.org; Mon, 03 Mar 2025 08:32:24 +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 1tp17f-001MI9-4Y for pgsql-hackers@arkaria.postgresql.org; Mon, 03 Mar 2025 08:25:59 +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 1tp17e-001MGI-K8 for pgsql-hackers@lists.postgresql.org; Mon, 03 Mar 2025 08:25:58 +0000 Received: from mail.postgrespro.ru ([93.174.131.139]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1tp17a-000fRJ-1N for pgsql-hackers@lists.postgresql.org; Mon, 03 Mar 2025 08:25:57 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=postgrespro.ru; s=mx2023; t=1740990354; bh=9Vouhm29p7S0JhvxZSxB9hU3lphgdGOT3dlQI2pGL3Q=; h=Message-ID:Date:User-Agent:Subject:To:References:From:In-Reply-To: From; b=uSHybXUXQbRPncWIirWd30NgDK97yZFLUYSb5f70nScLYVIQB8MNNG+/zCOtWkiWe IwjVS5fRjBo+oQCiEMGe/hyUdJyL8T7AMr6fH9IxJAhud+xQ1bxfe3jBODWlFk/vxa zeZXXisZhfouYBbK/uDsODbcz/WYmaazaK0olrCsM7bg0baUtsMue+5c2pBeblwbNL V542NNd2/vDRIiJYGhDZ7RWNJUe+fxGqJrpzak/0Zz8Dcd0KRWlQnvq9/UT6AkqNRU gVMBzc+tj/pSjTWgSjPSROpqxQsIyJ1+jADF+8w8T+MFgMc3DKp65m4waMi48fLY4+ xEo775hZJmktg== Received: from [10.4.12.74] (unknown [93.174.131.141]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (Client did not present a certificate) (Authenticated sender: a.rybakina@postgrespro.ru) by mail.postgrespro.ru (Postfix/587) with ESMTPSA id 582B860846; Mon, 3 Mar 2025 11:25:54 +0300 (MSK) Content-Type: multipart/alternative; boundary="------------1HVwl9OOsh6FYbxJePDid28H" Message-ID: Date: Mon, 3 Mar 2025 11:25:54 +0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: making EXPLAIN extensible To: Robert Haas , PostgreSQL Hackers References: Content-Language: en-US From: Alena Rybakina In-Reply-To: X-KSMG-AntiPhishing: NotDetected, bases: 2025/03/03 07:22:00 X-KSMG-AntiSpam-Interceptor-Info: not scanned X-KSMG-AntiSpam-Status: not scanned, disabled by settings X-KSMG-AntiVirus: Kaspersky Secure Mail Gateway, version 2.1.0.7854, bases: 2025/03/03 06:47:00 #27558135 X-KSMG-AntiVirus-Status: NotDetected, skipped X-KSMG-LinksScanning: not scanned, disabled by settings X-KSMG-Message-Action: skipped X-KSMG-Rule-ID: 1 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk This is a multi-part message in MIME format. --------------1HVwl9OOsh6FYbxJePDid28H Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Hi! I agree with your idea to expand the explain. On 28.02.2025 22:26, Robert Haas wrote: > 0002 provides hooks that you can use to make your new EXPLAIN options > actually do something. In particular, this adds a new hook that is > called once per PlanState node, and a new nook that is called once per > PlannedStmt. Each is called at an appropriate point for you to tack on > more output after what EXPLAIN would already produce. > > 0003 adds a new contrib module called pg_overexplain, which adds > EXPLAIN (DEBUG) and EXPLAIN (RANGE_TABLE). I actually think this is > quite useful for planner hacking, and maybe a few more options would > be, too. Right now, if you want to see stuff that EXPLAIN doesn't > clearly show, you have to use SET debug_print_plan = true, and that > output is so verbose that finding the parts you actually want to see > is quite difficult. Assuming it gives you the details you need, > EXPLAIN (RANGE_TABLE) looks way, way better to me, and if we end up > committing these patches I anticipate using this semi-regularly. > > > There are plenty of debatable things in this patch set, and I mention > some of them in the commit messages. The hook design in 0002 is a bit > simplistic and could be made more complex; there's lots of stuff that > could be added to or removed from 0003, much of which comes down to > what somebody hacking on the planner would actually want to see. I'm > happy to bikeshed all of that stuff; this is all quite preliminary and > I'm not committed to the details. The only thing that would disappoint > me is if somebody said "this whole idea of making EXPLAIN extensible > is stupid and pointless and we shouldn't ever do it." I will argue > against that vociferously. I think even what I have here is enough to > disprove that hypothesis, but I have a bunch of ideas about how to do > more. Some of those require additional infrastructure and are best > proposed with that other infrastructure; some can be done with just > this, but I ran out of time to code up examples so here is what I have > got so far. > > Hope you like it, sorry if you don't. while writing the AQO extension [0] we were just adding a hook (we called it ExplainOnePlan_hook) similar to this one to add a description for the node used in the plan, in particular its identifier and the cardinality that is used during query planning. We also added a guc that allows user to disable this debug information, since it can only be useful when analyzing a problematic query, but not all the time. Therefore, I think this work is necessary and needed to provide the necessary output of additional information about the plan, which may be necessary for extensions like this. [0] https://github.com/postgrespro/aqo -- Regards, Alena Rybakina Postgres Professional --------------1HVwl9OOsh6FYbxJePDid28H Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 7bit
Hi! I agree with your idea to expand the explain.

On 28.02.2025 22:26, Robert Haas wrote:
0002 provides hooks that you can use to make your new EXPLAIN options
actually do something. In particular, this adds a new hook that is
called once per PlanState node, and a new nook that is called once per
PlannedStmt. Each is called at an appropriate point for you to tack on
more output after what EXPLAIN would already produce.

0003 adds a new contrib module called pg_overexplain, which adds
EXPLAIN (DEBUG) and EXPLAIN (RANGE_TABLE). I actually think this is
quite useful for planner hacking, and maybe a few more options would
be, too. Right now, if you want to see stuff that EXPLAIN doesn't
clearly show, you have to use SET debug_print_plan = true, and that
output is so verbose that finding the parts you actually want to see
is quite difficult. Assuming it gives you the details you need,
EXPLAIN (RANGE_TABLE) looks way, way better to me, and if we end up
committing these patches I anticipate using this semi-regularly.


There are plenty of debatable things in this patch set, and I mention
some of them in the commit messages. The hook design in 0002 is a bit
simplistic and could be made more complex; there's lots of stuff that
could be added to or removed from 0003, much of which comes down to
what somebody hacking on the planner would actually want to see. I'm
happy to bikeshed all of that stuff; this is all quite preliminary and
I'm not committed to the details. The only thing that would disappoint
me is if somebody said "this whole idea of making EXPLAIN extensible
is stupid and pointless and we shouldn't ever do it." I will argue
against that vociferously. I think even what I have here is enough to
disprove that hypothesis, but I have a bunch of ideas about how to do
more. Some of those require additional infrastructure and are best
proposed with that other infrastructure; some can be done with just
this, but I ran out of time to code up examples so here is what I have
got so far.

Hope you like it, sorry if you don't.

while writing the AQO extension [0] we were just adding a hook (we called it ExplainOnePlan_hook) similar to this one to add a description for the node used in the plan, in particular its identifier and the cardinality that is used during query planning. We also added a guc that allows user to disable this debug information, since it can only be useful when analyzing a problematic query, but not all the time. Therefore, I think this work is necessary and needed to provide the necessary output of additional information about the plan, which may be necessary for extensions like this.

[0] https://github.com/postgrespro/aqo

-- 
Regards,
Alena Rybakina
Postgres Professional
--------------1HVwl9OOsh6FYbxJePDid28H--