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 1tubkv-00A98H-8l for pgsql-hackers@arkaria.postgresql.org; Tue, 18 Mar 2025 18:33:37 +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 1tubkt-002XDx-0l for pgsql-hackers@arkaria.postgresql.org; Tue, 18 Mar 2025 18:33:35 +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 1tubks-002XCh-KE for pgsql-hackers@lists.postgresql.org; Tue, 18 Mar 2025 18:33:34 +0000 Received: from fout-a5-smtp.messagingengine.com ([103.168.172.148]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1tubko-003c7M-2Y for pgsql-hackers@postgresql.org; Tue, 18 Mar 2025 18:33:34 +0000 Received: from phl-compute-07.internal (phl-compute-07.phl.internal [10.202.2.47]) by mailfout.phl.internal (Postfix) with ESMTP id E4A091382D29; Tue, 18 Mar 2025 14:33:29 -0400 (EDT) Received: from phl-mailfrontend-02 ([10.202.2.163]) by phl-compute-07.internal (MEProxy); Tue, 18 Mar 2025 14:33:29 -0400 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=fm1; t=1742322809; x=1742409209; bh=K InVDlpgcXlg7RWZue9Nfgu+nQeepeI4oAwUaturDy8=; b=a8V6cHNYo4Ifh177c Lt/8sQcNHaBiSjolg8slV2vXrIcyT8hxzBplR71LkKORN363NNEo+jXCOt3iZiT4 X7l0uZ+S6GRwkYwBFMIm2OubYe6wov9syaxi4F/CKKja/wsIm+6ZUXRfDNCXpL9M aH12sGX6qKq88BEjYZYkDlE5rGzLu+tVmVoGXTaNVFiirKuCIvTE3EIm9u1xOb18 Q/4UWi05jkPJAsOLJ1etq7SLGqWijg5EmyRRK2cjEwXqm2on2HJdQ1SBTlusEeIr SGKzXlv3PQV82u5hcAB8sk4c2ZEwUdPnT6BHg/tgkMs1/8BGrriKqj6H9dOq7heb 0/89A== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefvddrtddtgddugeefudejucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdggtfgfnhhsuhgsshgtrhhisggv pdfurfetoffkrfgpnffqhgenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpih gvnhhtshculddquddttddmnecujfgurhepfffhvfevuffkgggtugfgjgesthekredttddt jeenucfhrhhomheplmhlvhgrrhhoucfjvghrrhgvrhgruceorghlvhhhvghrrhgvsegrlh hvhhdrnhhoqdhiphdrohhrgheqnecuggftrfgrthhtvghrnhepvdehueffhefgueekueef heehgffhuefgfedukeejveduffegffekgeffffevgeehnecuffhomhgrihhnpegvnhhtvg hrphhrihhsvggusgdrtghomhenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhep mhgrihhlfhhrohhmpegrlhhvhhgvrhhrvgesrghlvhhhrdhnohdqihhprdhorhhgpdhnsg gprhgtphhtthhopeduledpmhhouggvpehsmhhtphhouhhtpdhrtghpthhtohepkhhouhes tghlvggrrhdqtghouggvrdgtohhmpdhrtghpthhtohepmhgrrhgtohhssehfuddtrdgtoh hmrdgsrhdprhgtphhtthhopeelvghrthhhrghlihhonheisehgmhgrihhlrdgtohhmpdhr tghpthhtohepghgvihgurghvrdhpghesghhmrghilhdrtghomhdprhgtphhtthhopehnrg hthhgrnhgusghoshhsrghrthesghhmrghilhdrtghomhdprhgtphhtthhopehprghvvghl rdhtrhhukhhhrghnohhvsehgmhgrihhlrdgtohhmpdhrtghpthhtoheprhgvshhhkhgvkh hirhhilhhlsehgmhgrihhlrdgtohhmpdhrtghpthhtoheprhhjuhhjuhduvdefsehgmhgr ihhlrdgtohhmpdhrtghpthhtoheprhhosggvrhhtmhhhrggrshesghhmrghilhdrtghomh X-ME-Proxy: Feedback-ID: ia2694551:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 18 Mar 2025 14:33:28 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alvh.no-ip.org; s=schmee; t=1742322805; bh=n4/mqcRyGrS0AkdcQlg6WIZ36wgbnGTKPeB2lAXBXnw=; h=Date:From:To:Cc:Subject:In-Reply-To:From; b=H4gaIyAMxlqfBgG8rqa+D206TwfpBJHZQl9MtGMSlg2KL1UteFZyMTKux0Dwxobcx kEnIdnFgA4ZYjee+L3sYLmjlrK2VuROiwMtec/M0JZ39DEmy8gd/0ilz4CBeIwQ91f zaxzBtHQ9df+fPoa82rIaKcRRfpRFh0HXvQM8YAupJF/QwJ1/E071sfGHOeSp1Dwzt bxym3B9h5A2o4CnYefiqDSk2tEWt7I7i1jygg6A1TmLRxzsAsnilOHns7mGCXOZhRD bHBI/4o4ICoWIFXPkxEnLaD3s7or6aHyAsUrnX6hckpKGgq0zv7k95gxC/apMwzH3p czvZ16YFq0yOA== Received: by schmee.alvh.no-ip.org (Postfix, from userid 1000) id 2DD4B87; Tue, 18 Mar 2025 19:33:25 +0100 (CET) Date: Tue, 18 Mar 2025 19:33:25 +0100 From: =?utf-8?Q?=C3=81lvaro?= Herrera To: Dmitry Dolgov <9erthalion6@gmail.com> Cc: Julien Rouhaud , Sami Imseih , Kirill Reshke , Sergei Kornilov , yasuo.honda@gmail.com, tgl@sss.pgh.pa.us, smithpb2250@gmail.com, vignesh21@gmail.com, michael@paquier.xyz, nathandbossart@gmail.com, stark.cfm@gmail.com, geidav.pg@gmail.com, marcos@f10.com.br, robertmhaas@gmail.com, david@pgmasters.net, pgsql-hackers@postgresql.org, pavel.trukhanov@gmail.com, Sutou Kouhei Subject: Re: pg_stat_statements and "IN" conditions Message-ID: <202503181833.mhpoqscwxfw3@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-Mar-18, Dmitry Dolgov wrote: > Thanks, much appreciated! I've inspected the diff between patches and > run few tests, at the first glance everything looks fine. Thanks for looking once more. > > I am tempted to say that explicit casts should also be considered > > squashable (that is, in IsSquashableConst() also allow the case of > > func->funcformat == COERCE_EXPLICIT_CAST). > > Well, I admit I may have been burned too much by the initial reception > of the patch and handled it too conservatively in this regard. I can totally understand that. I have added this and pushed. Hopefully nobody will hate this too much, and some people might even like it. By the way, I'm still open to adding the 'powers' mechanism that was discussed earlier and other simple additions on top of what's there now, if you have some spare energy to spend on this. (For full disclosure: the "powers" thing was discussed in a developer's meeting last year, and several people said they'd prefer to stick with 0001 and forget about powers, on the grounds that it produced query texts that were weird and invalid SQL. But now that we have the commented-out syntax, it's no longer invalid SQL, and maybe it's not so weird either.) But there are other proposals such as handling Params and whatnot. At this point, what we'd need for that is a more extensive test suite to show that we're not breaking other things ... > Agree, when put together with the OID limitation it doesn't look so bad. > Somehow I was thinking about the Sami's proposal and the discussion in more > abstract terms, Yeah, that happened to me too, and then I checked again and realized that my initial impression was wrong. > as if we talk about any arbitrary mutable functions to squash -- I > still would be cautious about hiding non-bootstrapped mutable > functions. Yeah, absolutely. One thing I noticed while going over the code, is that we say in some code comments that the list of elements only contributes the first and last elements to the jumble. But this is not true -- the list actually contributes _nothing at all_ to the jumble. I don't think this causes any terrible problems, but maybe somebody will discover that I'm wrong on that. This isn't trivial to solve, because if you try to add anything to the jumble from there, you'd break the first/last location pair matching. We could maybe fix this by returning the actual bottommost Const node from IsSquashableConstList() instead of whatever is wrapping it, and then arrange for _jumbleConst() to receive a boolean that turns off jumbling of the location. However, contributing nothing already makes such a query different from another query that has exactly one element, because that one jumbles that element. It could only be confused (in the sense of identical query_ids) with another list that has zero elements. Anyway, something to play with. BTW, it's fun to execute a query that's literally select col from tab where col in (1 /*, ... */); and then select col from tab where col in (1, 2); because now you have two entries in pg_stat_statements with visibly the same query text, but two different query_ids. I'm not terribly worried about this, because who uses a literal "/*, ... */" in a query anyway? And even if they do, it's easily explained. But jesters could probably get a good laugh messing about with these reports. Thanks for keeping at this for so long! -- Álvaro Herrera PostgreSQL Developer — https://www.EnterpriseDB.com/