Index scan problem

From: sarlav kumar <sarlavk(at)yahoo(dot)com>
To: pgsql-novice(at)postgresql(dot)org
Subject: Index scan problem
Date: 2004-11-16 22:38:35
Message-ID: 20041116223835.15589.qmail@web51308.mail.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

Hi All,

I have a query that does not use index scan and hence takes long time to execute.
It is a simple query:

SELECT value FROM test WHERE name='blah_blah';

and the "test" table has the following structure

Column | Type | Modifiers
name | character varying(50) | not null
value | text |
Indexes: test_pkey primary key btree (name)

The explain analyze output for the query is:

explain SELECT value FROM test WHERE name='blah_blah';
QUERY PLAN
--------------------------------------------------------------
Seq Scan on test (cost=0.00..1.82 rows=1 width=7)
Filter: (name = 'blah_blah'::character varying)
(2 rows)


Since name is a primary key, shouldn't the query use index scan on it??
However, if I force Postgres to use index scan by setting enable_seqscan to off, the query uses index scan on name.

Can someone tell how I can make the query to use index scan on name without having to force postgres?

Thanks in advance,
Saranya


---------------------------------
Do you Yahoo!?
Meet the all-new My Yahoo! Try it today!

Browse pgsql-novice by date

  From Date Subject
Next Message Rajan Bhide 2004-11-17 08:02:42 Syntax error in DROP CONSTRAINT
Previous Message Terry Lee Tucker 2004-11-16 21:18:13 Re: How to get current user