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 1tixOr-004DB2-9z for pgsql-hackers@arkaria.postgresql.org; Fri, 14 Feb 2025 15:14:41 +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 1tixOp-00BAap-DD for pgsql-hackers@arkaria.postgresql.org; Fri, 14 Feb 2025 15:14:40 +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 1tixMr-00B6ac-9W for pgsql-hackers@lists.postgresql.org; Fri, 14 Feb 2025 15:12:38 +0000 Received: from mail-pl1-x636.google.com ([2607:f8b0:4864:20::636]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1tixMq-000maI-0P for pgsql-hackers@postgresql.org; Fri, 14 Feb 2025 15:12:37 +0000 Received: by mail-pl1-x636.google.com with SMTP id d9443c01a7336-220ecbdb4c2so26635915ad.3 for ; Fri, 14 Feb 2025 07:12:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1739545955; x=1740150755; darn=postgresql.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=jzFYOOBQ1773o77XrsFsPjad4n7BOjk3n4LGND5EMaQ=; b=lIxPyvZNos2flArHMrVk0ZLllImnwZtxBYXukEyNV+sBom3V5DZiBKjSdk0K+shemB Ka0fduGsEOf1vC1AbWQbHHkmZvYrpdosMGKbI7fPSD5weNjZXvQUrLv/Vp+DbFqt2uvr oFbPVdHj4dGU+PN2nh1SRXV7NSUVuggLapbSycVV5EJ8SgoVTyj0c22QMUVuPUY4Sp/l PjNRj9j6YGZNMsZO49Cn2hJixqhhnxMlaKdDQF2HG6H63L2cYXZUmZELBvdRSIdaYjG5 c0xDZr2iVzMdHkMm/TLUYp1eIfODNToVgb0I5+YOPdRNqw93FvcWVpze2egEMS8bR48x 4j8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1739545955; x=1740150755; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=jzFYOOBQ1773o77XrsFsPjad4n7BOjk3n4LGND5EMaQ=; b=dYGlCudsY/KfrypSKlE2+remfxcFZ3SMmwUPNLSVbv0QTtCkArD/Hj01wGhyIRwwOi 1orCcFn/J9ZYxzgQRgzEFuuvVXqhVzucu/3nrghgWuHulrubcqsNCZSdopzuExyFKsHK sljPpYX6dvpyFtTCYFZBIrHG5SxjwjmuT7ECcMSIhB3cvMkTuSS9uRUXeXSruhZzSyWW c7yxqVZDo7vOCflbHKf4gRDTTp6Ac0MI5QeyjpDugftjbAKFJkCkT8i5ACfeGAbpIXW4 9BNq0E08B8jzCWp3RuuSiYdsavlX+p8M/onQsu6VxoOtkUXLaN3lYgWrzOaBrwfKljmX Ziuw== X-Forwarded-Encrypted: i=1; AJvYcCUzju/5MQmdWe5pkMas0P0mUZaF5qziL99VXMwMeDEfUIPlry0KPu8NMswdiR2RbMLurYPLAWKWPpohHebt@postgresql.org X-Gm-Message-State: AOJu0YwA5G3R+kRcjEKureVuG2ioc264Cepe9oRc+XmFOhoEt9CiRMzv I3LifP5Ox8h6/wIqWq8CiLz6biD7I2vgIAu36YP5uAer3pmlaeHm X-Gm-Gg: ASbGncsYgJFnhbYrqD4r5W7eTknLIRuZSjoMI+M/zHcyV487UlIeLcx80NVzwKkgOsI W1IqSx/MMA4ZiVuyAMaAeVFUUItC0I+kVHGRWQbp7x5r0ddJyMGsikOD6MWhQ1OvSQ5Ws9glLm8 JZA0weQHuqOTBiRO1RNHrNCQUj4hgArNBiLKnnCCTKlLFy9424+QtWVFeTGXpxjWunUCqvuDzUr zEeWYh0w4uunycx429bIg50v9JmkA97Ky5FROLzkLiE/0HS3m8xJCf3EilIPA5+4ap8CmURaM5Y o8TPVOM= X-Google-Smtp-Source: AGHT+IETllTLLGeMz0NvMg2EPouZjOoDS9jritcAAwc0lgGROwGGt6vILATSCMwkgJ3BLWtrp7Olfg== X-Received: by 2002:a17:902:e802:b0:220:cd9a:a177 with SMTP id d9443c01a7336-220cd9aa3d6mr118426615ad.9.1739545954950; Fri, 14 Feb 2025 07:12:34 -0800 (PST) Received: from jrouhaud ([115.43.41.38]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-220d545d039sm30018005ad.133.2025.02.14.07.12.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Feb 2025 07:12:33 -0800 (PST) Date: Fri, 14 Feb 2025 23:12:25 +0800 From: Julien Rouhaud To: Dmitry Dolgov <9erthalion6@gmail.com> Cc: Sami Imseih , =?iso-8859-1?Q?=C1lvaro?= Herrera , 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: References: <202502140936.lni5gtrycnzf@alvherre.pgsql> <7vjscmc3ybcibtyetdufrevyyl2hxpcpnofn2eygnne46owmql@gofozgqyq722> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Fri, Feb 14, 2025 at 03:56:32PM +0100, Dmitry Dolgov wrote: > > On Fri, Feb 14, 2025 at 10:39:45PM GMT, Julien Rouhaud wrote: > > There seems to be an off-by-1 error in parameter numbering when merging them. > > There are indeed three constants, but the second is not visible in the > query text. Maybe makes sense to adjust the number in this case, let me > try. Thanks! > > > Note that the query text as-is can still be successfully be used in an EXPLAIN > > (GENERIC_PLAN), but it might cause problem to third party tools that try to do > > something smarter about the parameters. > > Since the normalized query will be a valid one now, I hope that such > cases will be rare. On top of that it always will be option to not > enable constants squashing and avoid any troubles. It might not always be an option. I have seen application that create thousands of duplicated queryids just because they have a non deterministic amount of parameters they put in such IN () clauses. If that leads to a total number of unique (dbid, userid, queryid, toplevel) too big for a reasonable pg_stat_statements.max, they the only choice might be to enable the new merging parameter or deactivating pg_stat_statements. > Or do you have some > particular scenario of what might be problematic? I don't have a very specific scenario. It's mostly for things like trying to "un-jumble" a query, you may need to loop through the parameters and a missing number could be problematic. But since the overall number of parameters might change from execution to execution that's probably the least of the problems to deal with with this merging feature.