Re: BUG #19649: Qual pushdown into GROUP BY subqueries ignores non-equivalence-preserving references to grouping col - Mailing list pgsql-bugs

From Andrei Lepikhov
Subject Re: BUG #19649: Qual pushdown into GROUP BY subqueries ignores non-equivalence-preserving references to grouping col
Date
Msg-id 60c6b1f7-f435-4ca7-992a-482417af5130@gmail.com
Whole thread
List pgsql-bugs
On 03/09/2026 23:17, Andrey Rachitskiy wrote:
> This blocks wrapper-based finer equivalence at pushdown boundaries while
> preserving existing behavior for truly direct operands.
I don't like this fix. It causes regressions where we haven't had it before.
Let's see:

CREATE TABLE r(i int, s text, ts timestamptz);
EXPLAIN (COSTS OFF)
SELECT * FROM (SELECT i, count(*) c FROM r GROUP BY i) s WHERE i::text = '5';

Before:

 GroupAggregate
   Group Key: r.i
   ->  Sort
         Sort Key: r.i
         ->  Seq Scan on r
               Filter: ((i)::text = '5'::text)

With your fix:

 HashAggregate
   Group Key: r.i
   Filter: ((r.i)::text = '5'::text)
   ->  Seq Scan on r

I think, filter should be pushed down to the scan.

-- 
regards, Andrei Lepikhov,
pgEdge



pgsql-bugs by date:

Previous
From: Andrey Rachitskiy
Date:
Subject: Re: BUG #19653: "variable not found in subplan target list" during planning with parallel parameterized nested loop,
Next
From: Tom Lane
Date:
Subject: Re: BUG #19653: "variable not found in subplan target list" during planning with parallel parameterized nested loop,