Can anyone advise me how to get this to do an index lookup (Postgres 7.2)... It's really slow and I don't see why.
fsck_site=# create index story_link_date_idx on story_link(date);
SET ENABLE_SEQSCAN TO OFF;
CREATE
fsck_site=# SET ENABLE_SEQSCAN TO OFF;
SET VARIABLE
fsck_site=# \d story_link_date_idx
Index "story_link_date_idx"
Column | Type
--------+--------
date | bigint
btree
fsck_site=# explain select count(*) from story_link where date=1017062994;
NOTICE: QUERY PLAN:
Aggregate (cost=100031228.66..100031228.66 rows=1 width=0)
-> Seq Scan on story_link (cost=100000000.00..100031228.65 rows=4 width=0)
EXPLAIN
fsck_site=# SET ENABLE_SEQSCAN TO ON;
SET VARIABLE
fsck_site=# explain select count(*) from story_link where date=1017062994;
NOTICE: QUERY PLAN:
Aggregate (cost=31228.66..31228.66 rows=1 width=0)
-> Seq Scan on story_link (cost=0.00..31228.65 rows=4 width=0)
EXPLAIN
fsck_site=#
Please CC any comments to pubweb-phpbuilder.com@fsck.co.uk since I can't necessarily read all the posts on here.