X-Original-To: pgsql-sql@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 1FF18476141 for ; Sat, 3 May 2003 06:15:36 -0400 (EDT) Received: from unimm.unisoftbg.com (mail.unisoftbg.com [194.12.229.207]) by postgresql.org (Postfix) with ESMTP id B6516475CA9 for ; Sat, 3 May 2003 06:14:32 -0400 (EDT) Received: (qmail 19045 invoked by uid 507); 3 May 2003 10:16:53 -0000 Received: from unknown (HELO t1.unisoftbg.com) (pginfo%t1.unisoftbg.com@194.12.229.193) by 0 with SMTP; 3 May 2003 10:16:53 -0000 Message-ID: <3EB387F6.F3230162@t1.unisoftbg.com> Date: Sat, 03 May 2003 11:12:22 +0200 From: pginfo X-Mailer: Mozilla 4.03 [en] (Win95; I) MIME-Version: 1.0 To: "pgsql-sql@postgresql.org" Subject: problem with max and not using index on PK Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Spam-Status: No, hits=-4.1 required=5.0 tests=BAYES_10,NO_DNS_FOR_FROM,TO_ADDRESS_EQ_REAL version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200305/44 X-Sequence-Number: 13209 Hi, I am using PG 7.3.1 The query plan is: mydb=# explain analyze select max(IDS) from t_sk10; QUERY PLAN ------------------------------------------------------------------------------------------------------------------------ Aggregate (cost=61742.78..61742.78 rows=1 width=64) (actual time=11221.42..11221.43 rows=1 loops=1) -> Seq Scan on t_sk10 (cost=0.00..60076.22 rows=666622 width=64) (actual time=16.59..9968.00 rows=666622 loops=1) Total runtime: 11221.50 msec (3 rows) Time: 11222.68 ms The time is very big. For example if I start it on oracle, it take ~ 100 ms ! The column IDS is the PK. It is declared as name. I do not know the reason for not using index in this case. Also if I get another (not indexed column) and start also max, PG i working 4 time quicker as oracle and it is great. Regards, ivan.