Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id 9F1FA1337B4B for ; Tue, 26 Oct 2010 09:33:00 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.251]) (amavisd-maia, port 10024) with ESMTP id 84336-08 for ; Tue, 26 Oct 2010 12:32:53 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from hrndva-omtalb.mail.rr.com (hrndva-omtalb.mail.rr.com [71.74.56.122]) by mail.postgresql.org (Postfix) with ESMTP id 4B46F1335B36 for ; Tue, 26 Oct 2010 09:32:53 -0300 (ADT) X-Authority-Analysis: v=1.1 cv=NFUeGz0loTdi/T6hXKngYYtckjed7x3pKvNOqmBBK18= c=1 sm=0 a=uDd9quwinH0A:10 a=8nJEP1OIZ-IA:10 a=RAii6je2cdnAH6ATCOpc6g==:17 a=_Ixf_7qHAAAA:8 a=8mZ7lhrDqtKZ-t5qDmAA:9 a=GBAjklLBOoBBVertgz8A:7 a=MmdI10zcTQ_v-7iB8-ITtudGuaAA:4 a=wPNLvfGTeEIA:10 a=ryAo9hy1-OkA:10 a=6vsjEBoLwlAA:10 a=0tfO7MgyNwYA:10 a=RAii6je2cdnAH6ATCOpc6g==:117 X-Cloudmark-Score: 0 X-Originating-IP: 74.73.87.196 Received: from [74.73.87.196] ([74.73.87.196:51558] helo=[192.168.1.103]) by hrndva-oedge04.mail.rr.com (envelope-from ) (ecelerity 2.2.3.46 r()) with ESMTP id D8/69-12606-57AC6CC4; Tue, 26 Oct 2010 12:32:53 +0000 Message-ID: <4CC6CA76.1020509@vmsinfo.com> Date: Tue, 26 Oct 2010 08:32:54 -0400 From: Mladen Gogala User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.2.11) Gecko/20101013 Lightning/1.0b2 Thunderbird/3.1.5 MIME-Version: 1.0 To: pgsql-performance@postgresql.org Subject: Re: which one is faster References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.9 tagged_above=-10 required=5 tests=BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001 X-Spam-Level: X-Archive-Number: 201010/429 X-Sequence-Number: 40847 On 10/26/2010 6:56 AM, AI Rumman wrote: > Which one is faster? > select count(*) from talble > or > select count(id) from table > where id is the primary key. PostgreSQL doesn't utilize the access methods known as "FULL INDEX SCAN" and "FAST FULL INDEX SCAN", so the optimizer will generate the sequential scan in both cases. In other words, PostgreSQL will read the entire table when counting, no matter what. -- Mladen Gogala Sr. Oracle DBA 1500 Broadway New York, NY 10036 (212) 329-5251 www.vmsinfo.com