Re: finding a max value - Mailing list pgsql-performance

From James Antill
Subject Re: finding a max value
Date
Msg-id m37jtf62fd.fsf@code.and.org
Whole thread Raw
In response to finding a max value  (Edoardo Ceccarelli <eddy@expot.it>)
List pgsql-performance
Edoardo Ceccarelli <eddy@expot.it> writes:

> This is the query:
> select max(KA) from annuncio
>
> field KA is indexed and is int4,
>
> explaining gives:
> explain select max(KA) from annuncio;
> QUERY PLAN
> -----------------------------------------------------------------------
> Aggregate (cost=21173.70..21173.70 rows=1 width=4)
> -> Seq Scan on annuncio (cost=0.00..20326.76 rows=338776 width=4)
> (2 rows)
>
>
> wasn't supposed to do an index scan? it takes about 1sec to get the result.

 This is a known misfeature of max() in postgresql, see...

http://archives.postgresql.org/pgsql-performance/2003-12/msg00283.php

--
# James Antill -- james@and.org
:0:
* ^From: .*james@and\.org
/dev/null

pgsql-performance by date:

Previous
From: "Steinar H. Gunderson"
Date:
Subject: Odd sorting behaviour
Next
From: Guido Barosio
Date:
Subject: Re: query plan wierdness?