pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Scott Marlowe <smarlowe@g2switchworks.com>
To: Gerardo Herzig <gherzig@fmed.uba.ar>
Cc: pgsql-sql@postgresql.org
Subject: Re: index not being used. Why?
Date: Fri, 09 Mar 2007 13:58:31 -0600
Message-ID: <1173470311.20651.302.camel@state.g2switchworks.com> (raw)
In-Reply-To: <45F176CA.3050107@fmed.uba.ar>
References: <45F176CA.3050107@fmed.uba.ar>

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.





view thread (7+ messages)  latest in thread

Message-ID: <1173470311.20651.302.camel@state.g2switchworks.com>
Permalink:  ../1173470311.20651.302.camel@state.g2switchworks.com/
Also on:    postgresql.org/message-id/1173470311.20651.302.camel@state.g2switchworks.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: smarlowe@g2switchworks.com, gherzig@fmed.uba.ar
  Subject: Re: index not being used. Why?
  In-Reply-To: <1173470311.20651.302.camel@state.g2switchworks.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox