Received: from localhost.localdomain (postgresql.org [64.49.215.8]) by localhost (Postfix) with ESMTP id E1EA84765FE for ; Wed, 22 May 2002 13:29:31 -0400 (EDT) Received: from ecint.ecinet.com (smtp.eldocomp.com [205.159.99.3]) by postgresql.org (Postfix) with ESMTP id 6CEFD4762CB for ; Wed, 22 May 2002 13:27:57 -0400 (EDT) Received: from NWALKER (nwalker.ecinet.com [192.168.22.250]) by ecint.ecinet.com with SMTP (Microsoft Exchange Internet Mail Service Version 5.5.2653.13) id LNGCBA9X; Wed, 22 May 2002 10:27:56 -0700 Message-Id: <4.2.2.20020522102413.00b51428@ecint.ecinet.com> X-Sender: nwalke@ecint.ecinet.com X-Mailer: QUALCOMM Windows Eudora Pro Version 4.2.2 Date: Wed, 22 May 2002 10:28:08 -0700 To: "Thomas A. Lowery" , pgsql-admin From: Naomi Walker Subject: Re: Performance Problem Index Ignored, but why In-Reply-To: <20020521220113.A17282@stllnx1.stlassoc.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii"; format=flowed X-Archive-Number: 200205/180 X-Sequence-Number: 4355 I'm not sure how well this works in Postgres. For Informix, we could trick the optimizer into using an index with something like: Select colname from table where colname !=NULL. Specifically mentioning the column in the query was the trick. In esql/C, there were return parameters that then told you how many rows were found. >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 > >---------------------------(end of broadcast)--------------------------- >TIP 4: Don't 'kill -9' the postmaster