X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 44E40D1C9DB for ; Fri, 6 Feb 2004 21:52:37 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 19487-06 for ; Fri, 6 Feb 2004 17:52:34 -0400 (AST) Received: from davinci.ethosmedia.com (server228.ethosmedia.com [209.128.84.228]) by svr1.postgresql.org (Postfix) with ESMTP id 81033D1C517 for ; Fri, 6 Feb 2004 17:52:32 -0400 (AST) Received: from [63.195.55.98] (HELO 192.168.1.29) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) with ESMTP id 4383716; Fri, 06 Feb 2004 13:53:35 -0800 From: Josh Berkus Reply-To: josh@agliodbs.com Organization: Aglio Database Solutions To: Karl Denninger , pgsql-performance@postgresql.org Subject: Re: Why is query selecting sequential? Date: Fri, 6 Feb 2004 13:51:39 -0800 User-Agent: KMail/1.5.4 References: <20040206153602.B4910@Denninger.Net> In-Reply-To: <20040206153602.B4910@Denninger.Net> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200402061351.39084.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/101 X-Sequence-Number: 5625 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