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

From Jim C. Nasby
Subject Re: MAX/MIN optimization via rewrite (plus query rewrites generally)
Date
Msg-id 20041111041734.GB56660@decibel.org
Whole thread Raw
In response to MAX/MIN optimization via rewrite (plus query rewrites generally)  (Mark Kirkwood <markir@coretech.co.nz>)
Responses Re: MAX/MIN optimization via rewrite (plus query rewrites  (Mark Kirkwood <markir@coretech.co.nz>)
List pgsql-hackers
On Thu, Nov 11, 2004 at 11:48:49AM +1300, Mark Kirkwood wrote:
> I am looking at implementing this TODO item. e.g. (max case):
> 
> rewrite
> SELECT max(foo) FROM bar
> as
> SELECT foo FROM bar ORDER BY foo DESC LIMIT 1
> if there is an index on bar(foo)
Out of curiosity, will you be doing this in such a way that 

SELECT min(foo), max(foo) FROM bar

will end up as

SELECT (SELECT foo FROM bar ORDER BY foo ASC LIMIT 1), (SELECT ... DESC
LIMIT 1)

?
-- 
Jim C. Nasby, Database Consultant               decibel@decibel.org 
Give your computer some brain candy! www.distributed.net Team #1828

Windows: "Where do you want to go today?"
Linux: "Where do you want to go tomorrow?"
FreeBSD: "Are you guys coming, or what?"


pgsql-hackers by date:

Previous
From: Aleksander Kmetec
Date:
Subject: Re: Reorganization of the translation files
Next
From: Greg Stark
Date:
Subject: Re: A modest proposal: get rid of GUC's USERLIMIT variable category