| From: | Andrei Lepikhov <lepihov(at)gmail(dot)com> |
|---|---|
| To: | Richard Guo <guofenglinux(at)gmail(dot)com>, Robert Haas <robertmhaas(at)gmail(dot)com> |
| Cc: | "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org> |
| Subject: | Re: issues with eager aggregation |
| Date: | 2026-11-02 13:10:52 |
| Message-ID: | 6e3bb6d2-e981-49a4-9e7d-f18ee06e94a1@gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
On 18/09/2026 01:58, Richard Guo wrote:
> On Fri, Sep 18, 2026 at 12:55 AM Robert Haas <robertmhaas(at)gmail(dot)com> wrote:
>> On Thu, Sep 17, 2026 at 10:58 AM Richard Guo <guofenglinux(at)gmail(dot)com> wrote:
>>> As for the division-by-zero case, I agree it's user-visible, but I
>>> think eager aggregation should follow the same rules as our existing
>>> transformations, which already evaluate expressions on rows that a
>>> join removes.
>
>> OK, good. So this isn't really doing something that is fundamentally
>> new, which is what I was fearing. Do you think this section should be
>> adjusted at all?
>
> Yes, I think it's worth saying that an expression can be evaluated on
> rows that don't appear in the result.
As far as I can see, the documentation still doesn’t clarify this point, and the
SQL:2023 standard doesn’t settle it explicitly either. I ran into the same issue
with pushing a Sort below a join, both in my proposal [1] and in the extension
that backports it.
But it isn’t specific to new optimisations: the existing Gather Merge and Merge
Append paths can already compute a sort key on rows that the join later removes,
so a text-to-integer cast in ORDER BY can fail on master (see the SQL script in
the attachment).
Attached is a draft paragraph for the “Expression Evaluation Rules” section.
Since it describes behaviour that already exists, it might be worth
back-patching to v19 together with the eager aggregation fixes.
[1] Try a presorted outer path when referenced by an ORDER BY prefix
https://www.postgresql.org/message-id/19a9265c-c441-4a43-bc0d-dac533438da0%40gmail.com
--
regards, Andrei Lepikhov,
pgEdge
| Attachment | Content-Type | Size |
|---|---|---|
| 0001-Explain-that-expressions-may-be-evaluated-on-rows-a-.patch | text/plain | 2.2 KB |
| order-clause-pushdown.sql | text/plain | 1.5 KB |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | vignesh C | 2026-11-02 13:25:49 | Re: WAL record CRC calculated incorrectly because of underlying buffer modification |
| Previous Message | Jonathan S. Katz | 2026-11-02 13:06:03 | Re: PostgreSQL 19 GA press release draft |