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)
---------------------------(end of broadcast)--------------------------- TIP 6: Have you searched our list archives?
http://archives.postgresql.org
