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

From: Andrei Lepikhov <lepihov(at)gmail(dot)com>
To: Andrey Rachitskiy <pl0h0yp1(at)gmail(dot)com>, 303677365(at)qq(dot)com, pgsql-bugs(at)lists(dot)postgresql(dot)org
Cc: Tender Wang <tndrwang(at)gmail(dot)com>
Subject: Re: BUG #19649: Qual pushdown into GROUP BY subqueries ignores non-equivalence-preserving references to grouping col
Date: 2026-09-04 15:12:20
Message-ID: 60c6b1f7-f435-4ca7-992a-482417af5130@gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: 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

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2026-09-04 15:27:11 Re: BUG #19653: "variable not found in subplan target list" during planning with parallel parameterized nested loop,
Previous Message Andrey Rachitskiy 2026-09-04 14:59:19 Re: BUG #19653: "variable not found in subplan target list" during planning with parallel parameterized nested loop,