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.98.2) (envelope-from ) id 1x93jf-00000001ieF-1maW for pgsql-bugs@arkaria.postgresql.org; Tue, 22 Sep 2026 16:52:51 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.98.2) (envelope-from ) id 1x93jd-000000006OO-215B for pgsql-bugs@arkaria.postgresql.org; Tue, 22 Sep 2026 16:52: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.98.2) (envelope-from ) id 1x93jd-000000006OF-0z1M for pgsql-bugs@lists.postgresql.org; Tue, 22 Sep 2026 16:52:49 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1x93ja-00000000hZb-3oYF for pgsql-bugs@lists.postgresql.org; Tue, 22 Sep 2026 16:52:48 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.18.1/8.18.1) with ESMTP id 68MGqhCS1188433; Tue, 22 Sep 2026 12:52:43 -0400 From: Tom Lane To: Andrey Rachitskiy cc: Andrei Lepikhov , 303677365@qq.com, pgsql-bugs@lists.postgresql.org, Tender Wang Subject: Re: BUG #19649: Qual pushdown into GROUP BY subqueries ignores non-equivalence-preserving references to grouping col In-reply-to: References: <19649-2cabf1440793cc71@postgresql.org> <60c6b1f7-f435-4ca7-992a-482417af5130@gmail.com> <7c27d19d-3324-4977-a8b2-ea89af0eac79@gmail.com> Comments: In-reply-to Andrey Rachitskiy message dated "Sun, 06 Sep 2026 18:09:36 +0500" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1188431.1790095963.1@sss.pgh.pa.us> Date: Tue, 22 Sep 2026 12:52:43 -0400 Message-ID: <1188432.1790095963@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Andrey Rachitskiy writes: > Refuse to push a non-operand reference to a grouping column below the > grouping boundary unless the grouping equality is image equality > (BTEQUALIMAGE_PROC). That covers jsonb, numeric, float8 and similar > types, and subsumes the old nondeterministic-collation check for > wrapped references. The more I think about it, the less I like this solution approach. The trouble with it is that in exchange for making ill-posed queries (with no real-world use-cases) seem to have stable semantics, you are going to cause a disastrous performance regression for perfectly fine queries that do have real-world use. I can't see us taking that tradeoff. Especially when the apparently stable semantics are in fact no such thing, so that there isn't any useful gain from making the code act that way. What we really need here, perhaps, is a way to mark functions that can distinguish values seen as equal by their datatype's default equality operator. I'm not sure of a good way to do that. If we did have such a marking, frankly what I would do with it would be less like "don't push down past aggregation" and more like "throw an error that this query has undefined results". Otherwise we're just going to replace bug reports of this shape with bug reports about the query's result being unstable. regards, tom lane