Received: from localhost (maia-2.hub.org [200.46.204.187]) by postgresql.org (Postfix) with ESMTP id B9C249FB550 for ; Fri, 9 Mar 2007 16:24:27 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.187]) (amavisd-new, port 10024) with ESMTP id 37940-01 for ; Fri, 9 Mar 2007 16:24:22 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey-1.7.4 Received: from fmed.uba.ar (mail.fmed.uba.ar [157.92.152.1]) by postgresql.org (Postfix) with ESMTP id 2F1AB9FB4D3 for ; Fri, 9 Mar 2007 16:24:24 -0400 (AST) Received: from www.webmail.fmed.uba.ar (localhost [127.0.0.1]) by fmed.uba.ar (Postfix) with SMTP id 84E224C29F6; Fri, 9 Mar 2007 17:35:11 -0300 (ART) Received: from 190.55.116.36 (SquirrelMail authenticated user gherzig) by www.webmail.fmed.uba.ar with HTTP; Fri, 9 Mar 2007 17:35:11 -0300 (ART) Message-ID: <27676.190.55.116.36.1173472511.squirrel@www.webmail.fmed.uba.ar> In-Reply-To: <1173470311.20651.302.camel@state.g2switchworks.com> References: <45F176CA.3050107@fmed.uba.ar> <1173470311.20651.302.camel@state.g2switchworks.com> Date: Fri, 9 Mar 2007 17:35:11 -0300 (ART) Subject: Re: index not being used. Why? From: gherzig@fmed.uba.ar To: "Scott Marlowe" Cc: pgsql-sql@postgresql.org User-Agent: SquirrelMail/1.4.2 MIME-Version: 1.0 Content-Type: text/plain;charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Priority: 3 Importance: Normal X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.638 tagged_above=0 required=5 tests=AWL, BAYES_50, NO_REAL_NAME, SPF_HELO_PASS, SPF_PASS X-Spam-Level: X-Archive-Number: 200703/132 X-Sequence-Number: 27770 Thanks all you guys. Indeed, populating the tables with 10.000 entrys make the things different, and now it uses all the indexes as i spect. It was just a matter of being pacient and loading more data to test it out and see. And, yes, i need to upgrade psql now. Actually the real server has an 8.2.0 engine. Thanks all you guys! Gerardo > On Fri, 2007-03-09 at 09:01, Gerardo Herzig wrote: >> Hi all. I have this 2 relations >> > > SNIP > >> Index Cond: ((upper((word)::text) ~>=~ 'TEST'::character >> varying) AND (upper((word)::text) ~<~'TESU'::character >> varying)) >> -> Hash (cost=9.08..9.08 rows=408 width=55) >> -> Seq Scan on pages (cost=0.00..9.08 rows=408 width=55) >> >> (8 rows) >> >> >> Watch the last row of the explain command. It makes a sequential scan >> on the pages table, like it is not using the index on the "id" field. >> >> The result itself is OK, but i will populate the tables so i think >> that later that sequential scan would be a problem. > > Welcome to the world of tomorrow! hehe. PostgreSQL uses a cost based > planner. It decided that an index would cost more than a seq scan, so > it chose the seq scan. As mentioned in other posts, you'll need to do > an analyze. Also, look up things like vacuum / autovacuum as well. > >> Im using postgres 8.1.3 > > You need to upgrade to 8.1.8 or whatever the latest version is by the > time this email gets to you :) 8.1.3 is about a year out of date. > > > -- Gerardo Herzig Direccion General de Organizacion y Sistemas Facultad de Medicina U.B.A.