Re: Why is query selecting sequential?

From: Josh Berkus <josh(at)agliodbs(dot)com>
To: Karl Denninger <karl(at)Denninger(dot)Net>, pgsql-performance(at)postgresql(dot)org
Subject: Re: Why is query selecting sequential?
Date: 2004-02-06 21:51:39
Message-ID: 200402061351.39084.josh@agliodbs.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

Karl,

> SubPlan
> -> Seq Scan on forumlog (cost=0.00..1.18 rows=1 width=8)
> Filter: ((login = '%s'::text) AND (forum = '%s'::text) AND
(number = $0))

> Why is the subplan using a sequential scan? At minimum the index on the
> post number ("forumlog_number") should be used, no? What would be even
> better would be a set of indices that allow at least two (or even all three)
> of the keys in the inside SELECT to be used.

It's using a seq scan because you have only 1 row in the table. Don't
bother testing performance before your database is populated.

PostgreSQL doesn't just use an index because it's there; it uses and index
because it's faster than not using one.

If there is more than one row in the table, then:
1) run ANALYZE forumlog;
2) Send us the EXPLAIN ANALYZE, not just the explain for the query.

--
-Josh Berkus
Aglio Database Solutions
San Francisco

In response to

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Karl Denninger 2004-02-06 22:22:32 Re: Why is query selecting sequential?
Previous Message Karl Denninger 2004-02-06 21:36:02 Why is query selecting sequential?