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

From Bruno Wolff III
Subject Re: MAX/MIN optimization via rewrite (plus query rewrites
Date
Msg-id 20041111054442.GA6138@wolff.to
Whole thread Raw
In response to Re: MAX/MIN optimization via rewrite (plus query rewrites  (Mark Kirkwood <markir@coretech.co.nz>)
Responses Re: MAX/MIN optimization via rewrite (plus query rewrites  (Mark Kirkwood <markir@coretech.co.nz>)
Re: MAX/MIN optimization via rewrite (plus query rewrites  (Greg Stark <gsstark@mit.edu>)
List pgsql-hackers
On Thu, Nov 11, 2004 at 17:57:42 +1300, Mark Kirkwood <markir@coretech.co.nz> wrote:
> Your example and ones like :
> 
> SELECT max(foo), count(foo) FROM bar
> SELECT max(a.foo1), max(b.foo2) FROM bar1 AS a NATURAL JOIN bar2 AS b
> 
> have made me realize that the scope of "what should be optimized" is 
> somewhat subtle.
> 
> I am inclined to keep it simple (i.e rather limited) for a first cut, 
> and if that works well, then look at extending to more complex rewrites.
> 
> What do you think?

I don't think you should be rewriting queries as much as providing
alternate plans and letting the rest of the optimizer decided which
plan to use. If you just rewrite a query you might lock yourself into
using a poor plan.


pgsql-hackers by date:

Previous
From: Bruce Momjian
Date:
Subject: Vacuum info clarification
Next
From: Tom Lane
Date:
Subject: Re: MAX/MIN optimization via rewrite (plus query rewrites generally)