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

From Tom Lane
Subject Re: BUG #19649: Qual pushdown into GROUP BY subqueries ignores non-equivalence-preserving references to grouping col
Date
Msg-id 1188432.1790095963@sss.pgh.pa.us
Whole thread
In response to Re: BUG #19649: Qual pushdown into GROUP BY subqueries ignores non-equivalence-preserving references to grouping col  (Andrei Lepikhov <lepihov@gmail.com>)
List pgsql-bugs
Andrey Rachitskiy <pl0h0yp1@gmail.com> 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



pgsql-bugs by date:

Previous
From: Tom Lane
Date:
Subject: Re: BUG #19713: WindowAgg qual pushdown gives wrong partition count when scale(numeric) distinguishes equal values
Next
From: shihao zhong
Date:
Subject: Re: BUG #19705: One NaN box makes a BRIN box_inclusion_ops index omit unrelated rows