X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id AC3D4D1B89A for ; Tue, 19 Aug 2003 05:48:03 -0300 (ADT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 01032-05 for ; Tue, 19 Aug 2003 05:47:53 -0300 (ADT) Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by svr1.postgresql.org (Postfix) with ESMTP id AA9F5D1B934 for ; Tue, 19 Aug 2003 05:47:50 -0300 (ADT) Received: from zeta.dmz-eu.st.com (ns2.st.com [164.129.230.9]) by beta.dmz-eu.st.com (STMicroelectronics) with SMTP id 2B32EDB74 for ; Tue, 19 Aug 2003 08:47:51 +0000 (GMT) Received: by zeta.dmz-eu.st.com (STMicroelectronics, from userid 0) id B07256158; Tue, 19 Aug 2003 08:47:50 +0000 (GMT) Received: from agx003.agr.st.com (localhost [127.0.0.1]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 0E1B41849 for ; Tue, 19 Aug 2003 08:47:49 +0000 (GMT) Received: from st.com (web.rdd.agr.st.com [164.130.32.138]) by agx003.agr.st.com (8.9.3 (PHNE_24419+JAGae58098)/8.9.3) with ESMTP id KAA11637 for ; Tue, 19 Aug 2003 10:47:48 +0200 (METDST) Message-ID: <3F41E343.AE3B5E@st.com> Date: Tue, 19 Aug 2003 10:43:47 +0200 From: Marco Vezzoli X-Mailer: Mozilla 4.76 [en] (X11; U; SunOS 5.8 sun4u) X-Accept-Language: en MIME-Version: 1.0 To: sql Subject: postgres 7.1.3: why does the query plan ignore indexes? Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200308/214 X-Sequence-Number: 14830 Hi, I know this question was asked many times, but please help me understand what I am doing wrong. I work with a postgresql 7.1.3 on Solaris 8 compiled with gcc 3.0.2 Some indexes are defined on a table ewsweb_test=> \d measures_product Index "measures_product" Attribute | Type ------------+---------- product_id | smallint btree ewsweb_test=> \d measures_date Index "measures_date" Attribute | Type -----------+-------------------------- date | timestamp with time zone btree but the query seems to ignore it. ewsweb_test=> explain select zero_yield, gross from measures where product_id=29 and date between '2003-03-12' and '2003-08-14'; NOTICE: QUERY PLAN: Seq Scan on measures (cost=0.00..12937.76 rows=254 width=12) EXPLAIN I know there is an option that alter the seq scan cost but I prefer to leave the optimizer as clean as possible. Thanks in advence for any help. Marco -- Marco Vezzoli tel. +39 039 603 6852 STMicroelectronics fax. +39 039 603 5055