Re: limits of max, min optimization

From: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
To: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: limits of max, min optimization
Date: 2022-07-18 14:24:03
Message-ID: 20220718142403.5jcopco7e44rch2w@alvherre.pgsql
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 2022-Jul-18, Pavel Stehule wrote:

> Hi
>
> 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.
>
> Is it true?

See preprocess_minmax_aggregates() in
src/backend/optimizer/plan/planagg.c

> select max(insert_date) from foo join boo on foo.boo_id = boo.id
> where foo.item_id = 100 and boo.is_ok

Maybe it is possible to hack that code so that this case can be handled
better.

--
Álvaro Herrera Breisgau, Deutschland — https://www.EnterpriseDB.com/

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2022-07-18 14:29:07 Re: limits of max, min optimization
Previous Message Andrey Borodin 2022-07-18 14:04:47 Re: Use fadvise in wal replay