Received: from relay2.austria.eu.net (endjinn.austria.eu.net [193.81.13.2]) by postgresql.org (8.11.3/8.11.1) with ESMTP id f388ZI852803 for ; Sun, 8 Apr 2001 04:35:28 -0400 (EDT) (envelope-from Mario.Weilguni@kpnqwest.com) Received: from wotan (wotan.sime.com [193.228.81.42]) by relay2.austria.eu.net (8.11.1/8.11.1) with SMTP id f388ZFL10823 for ; Sun, 8 Apr 2001 10:35:15 +0200 (MET DST) Content-Type: text/plain; charset="iso-8859-1" From: Mario Weilguni Reply-To: mweilguni@sime.com To: pgsql-general@postgresql.org Subject: strange query plan Date: Sun, 8 Apr 2001 10:35:00 +0200 X-Mailer: KMail [version 1.2] MIME-Version: 1.0 Message-Id: <01040810350000.00637@wotan> Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by postgresql.org id f388ao852909 X-Archive-Number: 200104/336 X-Sequence-Number: 7457 I've a table containing some sort of logs, the table layout ist: Attribute | Type | Modifier -----------+--------------------------+--------------------------------------- id | integer | not null default nextval('ids'::text) serverid | integer | not null ts | timestamp with time zone | default now() log | character varying(400) | not null Indices: i1, log_pkey primary key is id, and there is an additional index on serverid. The table contains ~ 1.4 mio of rows, I've used "vacuum analyze". Now when I type: explain select min(id)from log; NOTICE: QUERY PLAN: Aggregate (cost=45702.20..45702.20 rows=1 width=4) -> Seq Scan on log (cost=0.00..41978.36 rows=1489536 width=4) I don't understand why the index log_pkey is not used here. I guess it would be much cheaper to consult the index to get min(), max(), sum() and avg() instead of sequentially scanning ~500MB of data. Any idea? Thanks Best regards, Mario Weilguni -- =================================================== Mario Weilguni                 KPNQwest Austria GmbH  Senior Engineer Web Solutions Nikolaiplatz 4  tel: +43-316-813824         8020 graz, austria  fax: +43-316-813824-26       http://www.kpnqwest.at  e-mail: mario.weilguni@kpnqwest.com ===================================================