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 1rAM8J-006FvF-Ef for pgsql-performance@arkaria.postgresql.org; Tue, 05 Dec 2023 03:30:03 +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 1rAM8I-001zOE-5d for pgsql-performance@arkaria.postgresql.org; Tue, 05 Dec 2023 03:30:02 +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 1rAM8H-001zO5-Rj for pgsql-performance@lists.postgresql.org; Tue, 05 Dec 2023 03:30:01 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rAM8F-00A9Xs-99 for pgsql-performance@lists.postgresql.org; Tue, 05 Dec 2023 03:30:01 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 3B53Ttjw842922; Mon, 4 Dec 2023 22:29:55 -0500 From: Tom Lane To: Michael Paquier cc: Jerry Brenner , pgsql-performance@lists.postgresql.org Subject: Re: Does Postgres have consistent identifiers (plan hash value) for explain plans? In-reply-to: References: <756532.1701701844@sss.pgh.pa.us> Comments: In-reply-to Michael Paquier message dated "Tue, 05 Dec 2023 12:05:26 +0900" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <842920.1701746995.1@sss.pgh.pa.us> Date: Mon, 04 Dec 2023 22:29:55 -0500 Message-ID: <842921.1701746995@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Michael Paquier writes: > On Mon, Dec 04, 2023 at 09:57:24AM -0500, Tom Lane wrote: >> Jerry Brenner writes: >>> Both Oracle and SQL Server have >>> consistent hash values for query plans and that makes it easy to identify >>> when there are multiple plans for the same query. Does that concept exist >>> in later releases of Postgres (and is the value stored in the json explain >>> plan)? >> No, there's no support currently for obtaining a hash value that's >> associated with a plan rather than an input query tree. > PlannerGlobal includes a no_query_jumble that gets inherited by all > its lower-level nodes, so adding support for hashes compiled from > these node structures would not be that complicated. My point is that > the basic infrastructure is in place in the tree to be able to do > that, and it should not be a problem to even publish the compiled > hashes in EXPLAIN outputs, behind an option of course. Well, yeah, we could fairly easily activate that infrastructure for plans, but we haven't. More to the point, it's not clear to me that that would satisfy the OP's request for "consistent" hash values. The hashes would vary depending on object OID values, system version, possibly endianness, etc. I'm also wondering exactly what the OP thinks qualifies as different plans. Remembering the amount of fooling-around that's gone on with querytree hashes to satisfy various people's ill-defined desires for pg_stat_statements aggregation behavior, I'm not really eager to buy into the same definitional morass at the plan level. regards, tom lane