Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id 6BE64B5DF6A for ; Tue, 1 Nov 2011 21:09:56 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.243]) (amavisd-maia, port 10024) with ESMTP id 77509-02 for ; Wed, 2 Nov 2011 00:09:49 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.8.0-rc2 Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by mail.postgresql.org (Postfix) with ESMTP id BB991B5F38D for ; Tue, 1 Nov 2011 21:07:36 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.2/8.14.2) with ESMTP id pA207WFB000371; Tue, 1 Nov 2011 20:07:32 -0400 (EDT) To: Josh Kupershmidt cc: pgsql-docs Subject: Re: docs update for count(*) and index-only scans In-reply-to: References: <26833.1320187862@sss.pgh.pa.us> Comments: In-reply-to Josh Kupershmidt message dated "Tue, 01 Nov 2011 19:16:48 -0400" Date: Tue, 01 Nov 2011 20:07:31 -0400 Message-ID: <370.1320192451@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-3.101 tagged_above=-5 required=5 tests=BAYES_00=-1.9, RP_MATCHES_RCVD=-1.201 X-Spam-Level: X-Archive-Number: 201111/4 X-Sequence-Number: 7079 Josh Kupershmidt writes: > On Tue, Nov 1, 2011 at 6:51 PM, Tom Lane wrote: >> Well, it might need adjustment, but I don't think we should remove it >> outright. The people who complain that COUNT(*) is not O(1) are still >> going to be complaining. On tables that are not read-mostly, there's >> no reason to expect that index-only scans will even provide a material >> speed boost, let alone be close to free. > But the tone of the existing note suggests that users "may be > surprised" that our COUNT(*) is slower than other RDBMSs. So I guess > I'm wondering, are we really still that much slower than our > competitors for COUNT(*)? Ignoring MyISAM and similar lobotomized > engines, does any competitor have a much-faster way? It's the "lobotomized engines" that are the problem, IMO --- people coming from databases like mysql tend to think count(*) just means reading a table size counter that the engine has anyway. I'm not really sure how our index-only scans stack up against the likes of Oracle. For a read-mostly table they probably have to do a comparable amount of work, but I'm not real sure how occasional heap visits (for us) will compare to occasional rollback segement visits (for them). And they may be able to scan their indexes in physical order, which would help a fair amount. And the whole code path is probably a good bit more mature and better optimized on that side of the fence, too. regards, tom lane