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 1tiCJS-00Cj1P-1P for pgsql-hackers@arkaria.postgresql.org; Wed, 12 Feb 2025 12:57:58 +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 1tiCJN-009FWz-K9 for pgsql-hackers@arkaria.postgresql.org; Wed, 12 Feb 2025 12:57:54 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tiCJN-009FWr-4o for pgsql-hackers@lists.postgresql.org; Wed, 12 Feb 2025 12:57:54 +0000 Received: from fhigh-a5-smtp.messagingengine.com ([103.168.172.156]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1tiCJL-000Pad-1R for pgsql-hackers@lists.postgresql.org; Wed, 12 Feb 2025 12:57:52 +0000 Received: from phl-compute-01.internal (phl-compute-01.phl.internal [10.202.2.41]) by mailfhigh.phl.internal (Postfix) with ESMTP id 190AD114016F; Wed, 12 Feb 2025 07:57:50 -0500 (EST) Received: from phl-mailfrontend-02 ([10.202.2.163]) by phl-compute-01.internal (MEProxy); Wed, 12 Feb 2025 07:57:50 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :reply-to:subject:subject:to:to:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm3; t=1739365070; x=1739451470; bh=d qws4qD7eHStuXKrDVzqDq7tvBdbwoTFf3c86Fo6jaA=; b=S3U38HZ8TU4MZouN3 DkGeJlgevfOdtp2Eiv3tyfdV9Ig0P8I5bxAhFh3ovcG4wOGru6p/vksGswupD/dn wTrkxLqHS3Ryh8J4AAuqp0BuqDopG+h7tCIvNplYXi1rCxZ88CeueOBVwCtimgll QTaSV9BIdr34irw6S7EHYpWwQ2RRxzy0yseqnn7/vc8gmvrG76r17fX4cCWFmq+T Kajpnuen8FbzKgJvdrxxY+M75qrQPktHZM8uY5XhPcYE3CZwNd+hl5BO4VH3PFd2 EszHHd3sK5oE/xiHrOwSwWTtlDJ3105gb6HbQYfCk0ou1WCrNBlUW9l7ux9dRezK 7PwnA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefvddrtddtgdegfeelgecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpggftfghnshhusghstghrihgsvgdp uffrtefokffrpgfnqfghnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivg hnthhsucdlqddutddtmdenucfjughrpeffhffvvefukfggtggugfgjsehtkeertddttdej necuhfhrohhmpeetlhhvrghrohcujfgvrhhrvghrrgcuoegrlhhvhhgvrhhrvgesrghlvh hhrdhnohdqihhprdhorhhgqeenucggtffrrghtthgvrhhnpeekfeeiheekkefftdffgeeg tdffleekiefguddvkefgudfgleeutdeihfektedugfenucffohhmrghinhepghhithhhuh gsrdgtohhmpdgvnhhtvghrphhrihhsvggusgdrtghomhenucevlhhushhtvghrufhiiigv pedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpegrlhhvhhgvrhhrvgesrghlvhhhrdhnoh dqihhprdhorhhgpdhnsggprhgtphhtthhopeeipdhmohguvgepshhmthhpohhuthdprhgt phhtthhopehluhhkrghssehfihhtthhlrdgtohhmpdhrtghpthhtoheprhhjuhhjuhduvd efsehgmhgrihhlrdgtohhmpdhrtghpthhtohepshgrmhhimhhsvghihhesghhmrghilhdr tghomhdprhgtphhtthhopehpghhsqhhlqdhhrggtkhgvrhhssehlihhsthhsrdhpohhsth hgrhgvshhqlhdrohhrghdprhgtphhtthhopehmihgthhgrvghlsehprghquhhivghrrdig hiiipdhrtghpthhtohepmhgrrhhkohesphhgrghnrghlhiiivgdrtghomh X-ME-Proxy: Feedback-ID: ia2694551:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 12 Feb 2025 07:57:48 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alvh.no-ip.org; s=schmee; t=1739365067; bh=OzUkCKOvyHbUCC6pNaTciZ2pQvFSF4MagL5mZDTw5/Y=; h=Date:From:To:Cc:Subject:In-Reply-To:From; b=NcN3C7JjBM8PELzV48tVlRKbYTNGJm98dJPrtpIFy3fbs3Sh7OKqgHSIbqW77asPu 50QSCzvrGZh4QAKnxHlLBCky7ojOWIQGCZbSNDgeo0nr4cLNJZd44LkWpK2BlBpcEc MEjeazXQRu0tHfFEVi0hlOFwNf/YhAn/LrCwDL5BzWeg7yZ8jXSGHxNhAFQgSzEUvh DIXj2O1VR8RwxcrBRFMMQ2MPRfiE1xxzcZwPowA3mpHufGQnR7eeaWmpEfsXThekHX lhfdc3TvCm0/AfdrOGbVsKlYEIgPqiNUrXQJOPmlprRGswYpK6MnrGmsPmhukiXGWo 6y6BphymYRncQ== Received: by schmee.alvh.no-ip.org (Postfix, from userid 1000) id 385216D; Wed, 12 Feb 2025 13:57:47 +0100 (CET) Date: Wed, 12 Feb 2025 13:57:47 +0100 From: Alvaro Herrera To: Julien Rouhaud Cc: Sami Imseih , Michael Paquier , Lukas Fittl , PostgreSQL Hackers , Marko M Subject: Re: [PATCH] Optionally record Plan IDs to track plan changes for a query Message-ID: <202502121257.ev3s2uy4h4ym@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 2025-Feb-12, Julien Rouhaud wrote: > > FWIW, I think options to tweak queryId computation is something that > > should be in core. It was discussed earlier in the context of IN > > list merging; the patch for this currently has the guc for the > > feature in pg_stat_statements, but there was a discussion about > > actually moving this to core [1] Giving the user a way to control > > certain behavior about the queryId computation is a good thing to do > > in core; especially queryId is no longer just consumed in > > pg_stat_statements. Maybe the right answer is an enum GUC, not sure > > yet. > Well, the ability for extensions to override the actual queryid > calculation was the result of more than half a decade of strong > disagreements about it. And I'm definitely not volunteering to > reopen that topic :) Sorry, Michael already did. Anyway, I think that's different. We do support compute_query_id=off as a way for a custom module to compute completely different query IDs using their own algorithm, which I think is what you're referring to. However, the ability to affect the way the in-core algorithm works is a different thing: you still want in-core code to compute the query ID. Right now, the proposal in the other thread is that if you want to affect that algorithm in order to merge arrays to be considered a single query element regardless of its length, you set the GUC for that. Initially the GUC was in the core code. Then, based on review, the GUC was moved to the extension, _BUT_ the implementation was still in the core code: in order to activate it, the extension calls a function that modifies core code behavior. So there are more moving parts than before, and if you for whatever reason want that behavior but not the extension, then you need to write a C function. To me this is absurd. So what I suggest we do is return to having the GUC in the core code. Now I admit I'm not sure what the solution would be for the problem discussed in this subthread. Apparently the problem is related to temp tables and their changing OIDs. I'm not sure what exactly the proposal for a GUC is. I mean, what would the behavior change be? Maybe what you want is something like "if this table reference here is to a temp table, then instead of jumbling the OID then jumble the string 'pg_temp.tablename' instead", which would make the query ID be the same for all occurrences of that query in whatever backend return the same number, regardless both of what OID the temp schema for that backend is, and the table OID itself. Is there more to it than that? (The only difficulty I see here is how to get the table name when the only thing you have is the RangeTblEntry, which doesn't have the name but just the OID. I see in [1] that you simply do a syscache lookup, but it would be good to avoid that.) Maybe that sounds pretty obscure if you try to describe it too precisely, but if you don't think too hard about it it probably natural -- at least to me. So my next question is, do we really need this behavior to be configurable? Wouldn't it be better to make the default way to deal with temp tables in all cases? The current behavior seems rather unhelpful. I do note that what you do in pg_queryid, which is simply to ignore the table altogether, is probably not a great idea. Anyway, assuming we make a GUC of it (a big if!), let me talk a bit about GUC names. In the other thread, the list of GUC names in the submitted patch plus the ones I suggested are: query_id_const_merge query_id_merge_values query_id_merge_value_lists query_id_squash_constant_lists so maybe here I would consider something like query_id_merge_temp_tables query_id_squash_temporary_tables [1] https://github.com/rjuju/pg_queryid/blob/master/pg_queryid.c#L941 -- Álvaro Herrera PostgreSQL Developer — https://www.EnterpriseDB.com/ "The important things in the world are problems with society that we don't understand at all. The machines will become more complicated but they won't be more complicated than the societies that run them." (Freeman Dyson)