Re: Why is query selecting sequential? - Mailing list pgsql-performance

From Josh Berkus
Subject Re: Why is query selecting sequential?
Date
Msg-id 200402061351.39084.josh@agliodbs.com
Whole thread Raw
In response to Why is query selecting sequential?  (Karl Denninger <karl@Denninger.Net>)
Responses Re: Why is query selecting sequential?
List 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


pgsql-performance by date:

Previous
From: Karl Denninger
Date:
Subject: Why is query selecting sequential?
Next
From: Karl Denninger
Date:
Subject: Re: Why is query selecting sequential?