Received: from localhost.localdomain (postgresql.org [64.49.215.8]) by localhost (Postfix) with ESMTP id 25BC3475D66 for ; Tue, 21 May 2002 22:05:11 -0400 (EDT) Received: from smtp.comcast.net (smtp.comcast.net [24.153.64.2]) by postgresql.org (Postfix) with ESMTP id D1E72475AF9 for ; Tue, 21 May 2002 22:02:59 -0400 (EDT) Received: from stllnx1.stlassoc.com (pcp01376419pcs.selrsv01.pa.comcast.net [68.80.68.209]) by mtaout03.icomcast.net (iPlanet Messaging Server 5.1 HotFix 0.6 (built Apr 26 2002)) with ESMTP id <0GWH00MY6PP3GN@mtaout03.icomcast.net> for pgsql-admin@postgresql.org; Tue, 21 May 2002 22:03:04 -0400 (EDT) Received: from tlowery by stllnx1.stlassoc.com with local (MasqMail 0.1.8c) id 17ALRC-0by-00 for pgsql-admin@postgresql.org; Tue, 21 May 2002 22:01:14 -0400 Date: Tue, 21 May 2002 22:01:13 -0400 From: "Thomas A. Lowery" Subject: Performance Problem Index Ignored, but why To: pgsql-admin Message-id: <20020521220113.A17282@stllnx1.stlassoc.com> MIME-version: 1.0 Content-type: text/plain; charset=us-ascii Content-transfer-encoding: 7BIT Content-disposition: inline User-Agent: Mutt/1.2.5.1i X-Operating-System: Linux/2.4.9-31 (i586) X-Uptime: 9:23pm up 2 days, 4:04, 16 users, load average: 0.95, 0.68, 0.47 X-Archive-Number: 200205/177 X-Sequence-Number: 4352 I've the task of porting a current Oracle application to PostgreSQL. Database: 7.2.1 OS: Linux 2.4.9-13smp I've an odd thing happening with a query. Using a simple table: Table "state_tst" Column | Type | Modifiers ---------+----------------------+----------- id | integer | not null v_state | character varying(2) | f_state | character(2) | Indexes: st_f_state_idx, st_v_state_idx Primary key: state_tst_pkey id is a sequence number and primary key, v_state and f_state are 2 character U.S. States. I created v_state as varchar(2) and f_state as char(2) to test if the query explained/performed differently (it doesn't). CREATE INDEX st_v_state_idx ON state_tst USING btree (v_state); CREATE INDEX st_f_state_idx ON state_tst USING btree (f_state); Load the table using a copy from ... vacuum verbose analyze state_tst; Total rows: 14309241 Queries using either f_state = or v_state = explain (and appear to execute) using a sequential scan. Resulting in 60 - 80 second query times. Can I force the use of an index? Or do I have something wrong? Any ideas? pg_test=# explain select count(*) from state_tst where f_state = 'PA'; NOTICE: QUERY PLAN: Aggregate (cost=277899.65..277899.65 rows=1 width=0) -> Seq Scan on state_tst (cost=0.00..277550.51 rows=139654 width=0) EXPLAIN