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 1thvMN-008c9E-RH for pgsql-hackers@arkaria.postgresql.org; Tue, 11 Feb 2025 18:51:51 +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 1thvML-00EG0W-R8 for pgsql-hackers@arkaria.postgresql.org; Tue, 11 Feb 2025 18:51:49 +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 1thvML-00EG0K-0K for pgsql-hackers@lists.postgresql.org; Tue, 11 Feb 2025 18:51:49 +0000 Received: from fhigh-b2-smtp.messagingengine.com ([202.12.124.153]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1thvMI-000GhD-2v for pgsql-hackers@postgresql.org; Tue, 11 Feb 2025 18:51:48 +0000 Received: from phl-compute-01.internal (phl-compute-01.phl.internal [10.202.2.41]) by mailfhigh.stl.internal (Postfix) with ESMTP id C3C0F2540104; Tue, 11 Feb 2025 13:51:45 -0500 (EST) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-01.internal (MEProxy); Tue, 11 Feb 2025 13:51:46 -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=1739299905; x=1739386305; bh=+ JMd8N/tzKhtTJFStia/ud1SyvvaMzfrC87RX0kHCLU=; b=ii2K13XgmP4QtBVMD w9m/xyHlvodkyiEAMkVG8tlz7RKECbX6tlqk/K+VwUPZHv946j4OMVb9rhpr4mMy 9yKVb2gh1iAm6Z8NW9gB5rqqZ8jtTzsgTy/0TmMYJ5G7A+FBHAYjlZ/TtJAQl1B9 5Rp4TTScPa0gNeDfyPO17Fx+AGtbwHxeNCwgkOlFGWMy8JwOPDmpFdfdePrmtWt3 r7EGfhssN2/ew9HATnZLd2NqvxFOqLOTm5h3WRteMSGmpoVfEFgMmw3Ix7bT3aMz uCVzs4GVggXyiN+Oc0p5f/SoFc8H5k9wuVHBv9eSYHPHnvhI+9yw8vxp8ZMuYMDW RWjxQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefvddrtddtgdegudejjecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpggftfghnshhusghstghrihgsvgdp uffrtefokffrpgfnqfghnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivg hnthhsucdlqddutddtmdenucfjughrpeffhffvvefukfggtggugfgjsehtkeertddttdej necuhfhrohhmpemllhhvrghrohcujfgvrhhrvghrrgcuoegrlhhvhhgvrhhrvgesrghlvh hhrdhnohdqihhprdhorhhgqeenucggtffrrghtthgvrhhnpedvheeuffehgfeukeeufeeh hefghfeugfefudekjeevudffgeffkeegffffveegheenucffohhmrghinhepvghnthgvrh hprhhishgvuggsrdgtohhmnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehm rghilhhfrhhomheprghlvhhhvghrrhgvsegrlhhvhhdrnhhoqdhiphdrohhrghdpnhgspg hrtghpthhtohepudekpdhmohguvgepshhmthhpohhuthdprhgtphhtthhopehkohhusegt lhgvrghrqdgtohguvgdrtghomhdprhgtphhtthhopehmrghrtghoshesfhdutddrtghomh drsghrpdhrtghpthhtoheplegvrhhthhgrlhhiohhnieesghhmrghilhdrtghomhdprhgt phhtthhopehgvghiuggrvhdrphhgsehgmhgrihhlrdgtohhmpdhrtghpthhtohepnhgrth hhrghnuggsohhsshgrrhhtsehgmhgrihhlrdgtohhmpdhrtghpthhtohepphgrvhgvlhdr thhruhhkhhgrnhhovhesghhmrghilhdrtghomhdprhgtphhtthhopehrvghshhhkvghkih hrihhllhesghhmrghilhdrtghomhdprhgtphhtthhopehrohgsvghrthhmhhgrrghssehg mhgrihhlrdgtohhmpdhrtghpthhtohepshgrmhhimhhsvghihhesghhmrghilhdrtghomh X-ME-Proxy: Feedback-ID: ia2694551:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 11 Feb 2025 13:51:44 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alvh.no-ip.org; s=schmee; t=1739299903; bh=BDQqwkKlxz4gfOuvK+yn6znfmOSkQ3Omeai5csAqkOs=; h=Date:From:To:Cc:Subject:In-Reply-To:From; b=DO3JyVk42qFjtx4NgxXXqIB+km27n+BAp7BHnwxVguPq//dE8O7jpn8sDkBwN1sUP dqgoqnY/8wG3MaCZKNJ8TSoZCO0EkHMc58K2iaKFH2eJjX27v81U8SLnVk5tC4WuTX DvjuK1dwJZCwR54n+Acv+smqk/yP192hhF+grXZYj2b4VQhGx7ZMyiPNu/fVRRxnTS jy6CvHTlyJqb8XAw1uxmmKOCNy+EKiIP4r+NZtT0BQrTsBQwAJAUtd1uM88P4c9ABJ B1pdSrFRmj5WCX+omsowD4YCklqvunRmN7wB35LmKKPZj5aFXnsVuX9iqisRoO3IO0 OCrygSauqWoGg== Received: by schmee.alvh.no-ip.org (Postfix, from userid 1000) id 5C48E1B; Tue, 11 Feb 2025 19:51:43 +0100 (CET) Date: Tue, 11 Feb 2025 19:51:43 +0100 From: =?utf-8?Q?=C3=81lvaro?= Herrera To: Dmitry Dolgov <9erthalion6@gmail.com> Cc: 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: <202502111851.yfhldozu4c6y@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-11, Dmitry Dolgov wrote: > > On Tue, Feb 11, 2025 at 10:49:59AM GMT, Sami Imseih wrote: > > I have only looked at 0001, but I am wondering why > > query_id_const_merge is a pg_stat_statements GUC > > rather than a core GUC? > > It was moved from being a core GUC into a pg_stat_statements GUC on the request > from the reviewers. Community tries to prevent adding more and more core GUCs > into PostgreSQL. I understand, but I tend to disagree with the argument because it's okay to simplify things that can be simplified, but if simplifying makes them more complex, then it goes against the original desire for simplicity anyway. My impression is that it would be better to put it back. (Otherwise, how do you document the behavior that pg_stat_activity suddenly emits different query_ids than before because you installed pg_stat_statement and enabled this feature? It just doesn't make much sense.) > > I suppose this is telling us that detecting the case with consts wrapped > > in casts is not really optional. (Dmitry said this was supported at > > early stages of the patch, and now I'm really curious about that > > implementation because what IsMergeableConstList sees is a FuncExpr that > > invokes the cast function for float8 to int4.) > > Yes, those cases in question are usually FuncExpr. The original patch > implementation used to handle that via simplifying the node with > eval_const_expressions to figure out if the value we work with is a constant. > This approach was marked as too risky by reviewers, as this could reach a lot > of unexpected functionality in the mutator part. Hmm, what about doing something much simpler, such as testing whether there's just a CoerceViaIO/RelabelType around a Const or a one-parameter function call of an immutable boostrap-OID function that has a Const as argument, and trivial cases like that? Something very very simple that's going to catch the majority of cases without anything as complex as a node walker. Maybe something like statext_is_compatible_clause_internal() can be an inspiration (and even that is far more complex than we need here.) -- Álvaro Herrera PostgreSQL Developer — https://www.EnterpriseDB.com/ "If it is not right, do not do it. If it is not true, do not say it." (Marcus Aurelius, Meditations)