Received: from localhost (maia-2.hub.org [200.46.204.187]) by postgresql.org (Postfix) with ESMTP id CCB5D9FB487 for ; Fri, 1 Jun 2007 13:59:10 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.187]) (amavisd-maia, port 10024) with ESMTP id 44714-09 for ; Fri, 1 Jun 2007 13:59:05 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.5 Received: from crestone.coronasolutions.com (crestone.coronasolutions.com [66.45.104.24]) by postgresql.org (Postfix) with ESMTP id D6DAE9FB480 for ; Fri, 1 Jun 2007 13:59:06 -0300 (ADT) Received: from localhost (localhost.localdomain [127.0.0.1]) by crestone.coronasolutions.com (Postfix) with ESMTP id 9084B644751; Fri, 1 Jun 2007 10:59:05 -0600 (MDT) Received: from crestone.coronasolutions.com ([127.0.0.1]) by localhost (crestone.coronasolutions.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 21367-10; Fri, 1 Jun 2007 10:59:01 -0600 (MDT) Received: from mac.local (c-71-196-213-0.hsd1.co.comcast.net [71.196.213.0]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by crestone.coronasolutions.com (Postfix) with ESMTP id A8969644759 for ; Fri, 1 Jun 2007 10:59:01 -0600 (MDT) Message-ID: <46605055.3070305@drivefaster.net> Date: Fri, 01 Jun 2007 10:59:01 -0600 From: Dan Harris User-Agent: Thunderbird 2.0.0.0 (Macintosh/20070326) MIME-Version: 1.0 To: pgsql-performance@postgresql.org Subject: Re: Seq Scan References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new-20030616-p10 (Debian) at coronasolutions.com X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200706/2 X-Sequence-Number: 25035 Tyler Durden wrote: > Hi, > I'm having some problems in performance in a simple select count(id) > from.... I have 700 000 records in one table, and when I do: > > # explain select (id) from table_name; > -[ RECORD 1 > ]---------------------------------------------------------------- > QUERY PLAN | Seq Scan on table_name (cost=0.00..8601.30 rows=266730 > width=4) > > I had created an index for id(btree), but still shows "Seq Scan". > What I'm doing wrong? > > Thanks, > Tyler > > ---------------------------(end of broadcast)--------------------------- > TIP 4: Have you searched our list archives? > > http://archives.postgresql.org select count(*) will *always* do a sequential scan, due to the MVCC architecture. See archives for much discussion about this. -Dan