X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 03C6BD1B1B7 for ; Wed, 7 Jul 2004 16:30:12 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 90596-05 for ; Wed, 7 Jul 2004 19:30:05 +0000 (GMT) Received: from mail.and.org (code.and.org [63.113.167.33]) by svr1.postgresql.org (Postfix) with ESMTP id 132AAD1B19F for ; Wed, 7 Jul 2004 16:30:01 -0300 (ADT) Received: from james by mail.and.org with local (Exim 4.30) id 1BiI7C-0000WL-Pu; Wed, 07 Jul 2004 15:29:58 -0400 To: Edoardo Ceccarelli Cc: pgsql-performance@postgresql.org Subject: Re: finding a max value From: James Antill References: <20040702075007.B448FCF4D52@www.postgresql.com> <20040702131258.GB25007@wolff.to> <40E5AE72.1080206@expot.it> Content-Type: text/plain; charset=US-ASCII Date: Wed, 07 Jul 2004 15:29:58 -0400 In-Reply-To: <40E5AE72.1080206@expot.it> (Edoardo Ceccarelli's message of "Fri, 02 Jul 2004 20:50:26 +0200") Message-ID: User-Agent: Gnus/5.1002 (Gnus v5.10.2) XEmacs/21.4 (Reasonable Discussion, linux) MIME-Version: 1.0 X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200407/35 X-Sequence-Number: 7426 Edoardo Ceccarelli 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