Re: Suggestion for aggregate function

From: Bruno Wolff III <bruno(at)wolff(dot)to>
To: Greg Stark <gsstark(at)mit(dot)edu>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Suggestion for aggregate function
Date: 2003-01-17 19:29:01
Message-ID: 20030117192901.GA3839@wolff.to
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2003-01-17 19:32:49 Re: Generate user/group sysids from a sequence?
Previous Message Robert Treat 2003-01-17 19:22:25 Re: Generate user/group sysids from a sequence?