On Fri, Jan 17, 2003 at 13:39:11 -0500,
Greg Stark <gsstark(at)mit(dot)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