Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id 65C4B6322EA for ; Wed, 14 Jul 2010 10:44:21 -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 20223-05 for ; Wed, 14 Jul 2010 13:44:12 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from smtp-vbr4.xs4all.nl (smtp-vbr4.xs4all.nl [194.109.24.24]) by mail.postgresql.org (Postfix) with ESMTP id E24BA632228 for ; Wed, 14 Jul 2010 10:44:13 -0300 (ADT) Received: from spoetnik.xs4all.nl (spoetnik.xs4all.nl [82.95.228.65]) by smtp-vbr4.xs4all.nl (8.13.8/8.13.8) with ESMTP id o6EDiBM3030369 for ; Wed, 14 Jul 2010 15:44:11 +0200 (CEST) (envelope-from reinoud.v@n.leeuwen.net) Received: by spoetnik.xs4all.nl (Postfix, from userid 1000) id DF7C71CC94; Wed, 14 Jul 2010 15:44:10 +0200 (CEST) Date: Wed, 14 Jul 2010 15:44:10 +0200 From: Reinoud van Leeuwen To: pgsql-sql@postgresql.org Subject: Re: Question on COUNT performance Message-ID: <20100714134410.GK62243@spoetnik.xs4all.nl> Mail-Followup-To: pgsql-sql@postgresql.org References: <20100714123029.GH62243@spoetnik.xs4all.nl> <4c3dbc01.0350e70a.18fa.388a@mx.google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4c3dbc01.0350e70a.18fa.388a@mx.google.com> User-Agent: Mutt/1.5.13 (2006-08-11) X-Virus-Scanned: by XS4ALL Virus Scanner X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-0.001 tagged_above=-5 required=5 tests=BAYES_20=-0.001, RCVD_IN_DNSWL_NONE=-0.0001 X-Spam-Level: X-Archive-Number: 201007/65 X-Sequence-Number: 34378 On Wed, Jul 14, 2010 at 07:30:39AM -0600, Joshua Tolley wrote: > > Have you tried 'select count (1)..."? > > If this helps at all, it's unlikely to help much. I remember having seen > discussion somewhere that there's an optimization such that count(*) and > count(1) do the same thing anyway, but I can't find it in the code > immediately. oops, I was thinking too much about Sybase (where is makes a huge difference, since the optimiser sees that everything it needs can be found in the index so the table does not have to be read at all). Reinoud -- __________________________________________________ "Nothing is as subjective as reality" Reinoud van Leeuwen reinoud.v@n.leeuwen.net http://reinoud.van.leeuwen.net kvk 27320762 __________________________________________________