Re: using max() aggregate

From: Louis-David Mitterrand <cunctator(at)apartia(dot)ch>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: using max() aggregate
Date: 2000-06-16 08:13:17
Message-ID: 20000616101317.C6451@styx
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Fri, Jun 16, 2000 at 02:05:53AM -0400, Tom Lane wrote:
> Louis-David Mitterrand <cunctator(at)apartia(dot)ch> writes:
> > I am trying to return the most recently updated record from a table:
> > SELECT max(stopdate) FROM auction;
> > and this works but only returns the timestamp, however if I try to get
> > another column with the aggregate it fails:
>
> Perhaps
>
> select * from auction order by stopdate desc limit 1;
>
> In 7.0 this should even be pretty quick, if you have an index on
> stopdate.

Thanks, yours seems to be the best solution.

The performance hit between max() and ORDER BY should be roughly
comparable?

--
Louis-David Mitterrand - ldm(at)apartia(dot)org - http://www.apartia.fr

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Giles Lean 2000-06-16 09:52:28 Re: optimization by removing the file system layer?
Previous Message Tom Lane 2000-06-16 06:49:23 Re: Performance for indexes on functions