Re: docs update for count(*) and index-only scans

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Josh Kupershmidt <schmiddy(at)gmail(dot)com>
Cc: pgsql-docs <pgsql-docs(at)postgresql(dot)org>
Subject: Re: docs update for count(*) and index-only scans
Date: 2011-11-02 00:07:31
Message-ID: 370.1320192451@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-docs

Josh Kupershmidt <schmiddy(at)gmail(dot)com> writes:
> On Tue, Nov 1, 2011 at 6:51 PM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> 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

In response to

Responses

Browse pgsql-docs by date

  From Date Subject
Next Message Jason Strimpel 2011-11-03 23:27:48 collation charts/tables
Previous Message Josh Kupershmidt 2011-11-01 23:16:48 Re: docs update for count(*) and index-only scans