Re: limits of max, min optimization - Mailing list pgsql-hackers

From Tom Lane
Subject Re: limits of max, min optimization
Date
Msg-id 696707.1658154547@sss.pgh.pa.us
Whole thread Raw
In response to Re: limits of max, min optimization  (Alvaro Herrera <alvherre@alvh.no-ip.org>)
Responses Re: limits of max, min optimization
List pgsql-hackers
Alvaro Herrera <alvherre@alvh.no-ip.org> writes:
> On 2022-Jul-18, Pavel Stehule wrote:
>> I am trying to fix one slow query, and found that optimization of min, max
>> functions is possible only when there is no JOIN in the query.

> See preprocess_minmax_aggregates() in
> src/backend/optimizer/plan/planagg.c
> Maybe it is possible to hack that code so that this case can be handled
> better.

The comments show this was already thought about:

     * We also restrict the query to reference exactly one table, since join
     * conditions can't be handled reasonably.  (We could perhaps handle a
     * query containing cartesian-product joins, but it hardly seems worth the
     * trouble.)

            regards, tom lane



pgsql-hackers by date:

Previous
From: Alvaro Herrera
Date:
Subject: Re: limits of max, min optimization
Next
From: Pavel Stehule
Date:
Subject: Re: limits of max, min optimization