why does explain tell me I'm using a seq scan?

From: Mark Harrison <mh(at)pixar(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: why does explain tell me I'm using a seq scan?
Date: 2003-11-08 00:11:58
Message-ID: 3FAC34CE.9020701@pixar.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I have indexed two columns in a table. Can somebody explain to me why
the first query below uses an Index Scan while the second uses a Seq
Scan?

Many TIA!
Mark

planb=# \d abcs
Table "public.abcs"
Column | Type | Modifiers
-----------+------------------------+-----------------------------------------------
abcid | integer | not null default nextval('abcid_seq'::text)
type | character varying(255) |
versionof | integer |
Indexes: abcs_pkey primary key btree (abcid),
abcs_versionof btree (versionof)

planb=# explain select type from abcs where abcid = 6339;
QUERY PLAN
----------------------------------------------------------------------------
Index Scan using abcs_pkey on abcs (cost=0.00..6.01 rows=1 width=145)
Index Cond: (abcid = 6339)
(2 rows)

planb=# explain select type from abcs where versionof = 6339;
QUERY PLAN
----------------------------------------------------------------
Seq Scan on abcs (cost=0.00..59182.10 rows=16137 width=145)
Filter: (versionof = 6339)
(2 rows)

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Rod Taylor 2003-11-08 00:19:24 Re: why does explain tell me I'm using a seq scan?
Previous Message Edwin Quijada 2003-11-07 23:50:36 Re: Recovery Data Cant Be!!!