Re: Suggestion for aggregate function - Mailing list pgsql-hackers

From Bruno Wolff III
Subject Re: Suggestion for aggregate function
Date
Msg-id 20030117192901.GA3839@wolff.to
Whole thread Raw
In response to Suggestion for aggregate function  (Greg Stark <gsstark@mit.edu>)
Responses Re: Suggestion for aggregate function  (Greg Stark <gsstark@mit.edu>)
List pgsql-hackers
On Fri, Jan 17, 2003 at 13:39:11 -0500, Greg Stark <gsstark@mit.edu> wrote:
> 
> So it would be possible to say for example:
> 
> select min(column1),lookup_min(column1,column2) from tab
> 
> to do the equivalent of:
> 
> select column1,column2 where column1=(select min(column1) from tab) limit 1
> 
> except it would be way more efficient. (Especially if there's an index on
> column1 and postgres were taught to use indexes for min/max, but that's a
> different story.)

The following will be more efficient than your function if there is a usable
index on column1:
select column1,column2 from tab order by column 1 limit 1


pgsql-hackers by date:

Previous
From: Greg Stark
Date:
Subject: Suggestion for aggregate function
Next
From: Robert Treat
Date:
Subject: Re: Generate user/group sysids from a sequence?