pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Josh Berkus <josh@agliodbs.com>
To: Karl Denninger <karl@Denninger.Net>
To: pgsql-performance@postgresql.org
Subject: Re: Why is query selecting sequential?
Date: Fri, 6 Feb 2004 13:51:39 -0800
Message-ID: <200402061351.39084.josh@agliodbs.com> (raw)
In-Reply-To: <20040206153602.B4910@Denninger.Net>
References: <20040206153602.B4910@Denninger.Net>

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




view thread (8+ messages)  latest in thread

Message-ID: <200402061351.39084.josh@agliodbs.com>
Permalink:  ../200402061351.39084.josh@agliodbs.com/
Also on:    postgresql.org/message-id/200402061351.39084.josh@agliodbs.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-performance@postgresql.org
  Cc: josh@agliodbs.com, karl@Denninger.Net
  Subject: Re: Why is query selecting sequential?
  In-Reply-To: <200402061351.39084.josh@agliodbs.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox