Re: MAX/MIN optimization via rewrite (plus query rewrites generally) - Mailing list pgsql-hackers

From Tom Lane
Subject Re: MAX/MIN optimization via rewrite (plus query rewrites generally)
Date
Msg-id 9858.1100197283@sss.pgh.pa.us
Whole thread Raw
In response to Re: MAX/MIN optimization via rewrite (plus query rewrites generally)  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
Bruno Wolff III <bruno@wolff.to> writes:
>   Tom Lane <tgl@sss.pgh.pa.us> wrote:
>> We know how to determine that an index matches an ORDER BY clause.
>> But what has an aggregate called MAX() got to do with ORDER BY?

> Wouldn't knowing an opclass and direction associated with an aggregrate
> function allow you to do this?

That's one way you could do it.  Another possibly cleaner way is to just
supply a sort operator (with the implication "the desired value is the
one ordered first by this operator") and then let the optimizer work out
which opclass(es) are relevant.  This would win if the same operator
appears in different opclasses, which is uncommon at the moment but
would not be so if we start offering "reverse sort" opclasses.

I think we covered all this ground before, though --- have you checked
the archives from the last time this was discussed?
        regards, tom lane


pgsql-hackers by date:

Previous
From: Greg Stark
Date:
Subject: Re: MAX/MIN optimization via rewrite (plus query
Next
From: Greg Stark
Date:
Subject: Re: MAX/MIN optimization via rewrite (plus query rewrites generally)