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

From Mark Kirkwood
Subject Re: MAX/MIN optimization via rewrite (plus query rewrites
Date
Msg-id 41931AEB.8010807@coretech.co.nz
Whole thread Raw
In response to Re: MAX/MIN optimization via rewrite (plus query rewrites  (Bruno Wolff III <bruno@wolff.to>)
List pgsql-hackers
There seems to be (as Tom indicated) a choice of approaches:

i) rewrite max/min querys and then plan 'em
ii) provide alternate plans based on presence of certain aggregate types 
in the query

when I first examined this TODO item, I was really thinking about i), 
but I suspect that ii) is probably the best approach.

regards

Mark



Bruno Wolff III wrote:

>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: "Jim C. Nasby"
Date:
Subject: Re: MAX/MIN optimization via rewrite (plus query rewrites
Next
From: Mark Kirkwood
Date:
Subject: Re: MAX/MIN optimization via rewrite (plus query rewrites