Re: MAX/MIN optimization via rewrite (plus query rewrites generally)

From: Bruno Wolff III <bruno(at)wolff(dot)to>
To: John Hansen <john(at)geeknet(dot)com(dot)au>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Alvaro Herrera <alvherre(at)dcc(dot)uchile(dot)cl>, Mark Kirkwood <markir(at)coretech(dot)co(dot)nz>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: MAX/MIN optimization via rewrite (plus query rewrites generally)
Date: 2004-11-11 14:00:01
Message-ID: 20041111140001.GA16640@wolff.to
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu, Nov 11, 2004 at 17:52:19 +1100,
John Hansen <john(at)geeknet(dot)com(dot)au> wrote:
> Why not just change the function all together to 'select $1 from $2
> order by $1 desc limit 1;'
>
> Is there ANY situation where max(col) as it is, would be faster?

Yes. A couple I can think of are:
When count(col) is also being used.
When a GROUP BY is being used and there isn't an index that can both be used
to do the grouping and col order within each group.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Bruno Wolff III 2004-11-11 14:07:53 Re: MAX/MIN optimization via rewrite (plus query rewrites
Previous Message Oleg Bartunov 2004-11-11 13:35:16 Re: ltree PostgreSQL Module