Re: Spped of max - Mailing list pgsql-general

From nconway@klamath.dyndns.org (Neil Conway)
Subject Re: Spped of max
Date
Msg-id 20020515002855.GA23279@klamath.dyndns.org
Whole thread Raw
In response to Spped of max  (Edmund Dengler <edmundd@eSentire.com>)
Responses Re: Spped of max
List pgsql-general
On Tue, May 14, 2002 at 01:27:30PM -0400, Edmund Dengler wrote:
> Greetings all!
>
> Quick question: how long should finding the maximum value in a column
> take?

This is a known issue: max() requires a sequential scan of the
table.

Since PostgreSQL allows user-defined aggregates, this is somewhat
difficult to optimize. No one has yet bothered to create special
cases for max(), min() and perhaps count(), although it could
probably be done.

I'd suggest simply using the workaround you noticed (ORDER BY,
LIMIT 1).

> Now, this type of thing gets me real worried about how good the
> optimizer really is.

The problem doesn't involve the optimizer, AFAICT.

Cheers,

Neil

--
Neil Conway <neilconway@rogers.com>
PGP Key ID: DB3C29FC

pgsql-general by date:

Previous
From: "Corey W. Gibbs"
Date:
Subject: Re: Using COPY
Next
From: Doug Fields
Date:
Subject: Re: Spped of max