From: paul rivers <rivers.paul@gmail.com>
To: Mark Mielke <mark@mark.mielke.cc>
Cc: josh@agliodbs.com, pgsql-performance@postgresql.org, Tom Lane <tgl@sss.pgh.pa.us>
Cc: Craig James <craig_james@emolecules.com>
Subject: Re: count * performance issue
Date: Fri, 07 Mar 2008 23:11:19 -0800
Message-ID: <47D23C17.7010207@gmail.com> (raw)
In-Reply-To: <47D224BE.1060001@mark.mielke.cc>
References: <f966c2ee0803052142l6a105678jfe2da92a0d9371@mail.gmail.com>
<47D00DB2.7040007@emolecules.com>
<18451.1204824562@sss.pgh.pa.us>
<200803071727.36146.josh@agliodbs.com>
<47D224BE.1060001@mark.mielke.cc>
Mark Mielke wrote:
> Josh Berkus wrote:
>>>> Count() on Oracle and MySQL is almost instantaneous, even for very
>>>> large tables. So why can't Postgres do what they do?
>>>>
>>> AFAIK the above claim is false for Oracle. They have the same
>>> transactional issues we do.
>>>
>>
>> Nope. Oracle's MVCC is implemented through rollback segments, rather than
>> non-overwriting the way ours is. So Oracle can just do a count(*) on the
>> index, then check the rollback segment for any concurrent
>> update/delete/insert activity and adjust the count. This sucks if there's
>> a *lot* of concurrent activity, but in the usual case it's pretty fast
>
> I read the "almost instantaneous" against "the above claim is false" and
> "Nope.", and I am not sure from the above whether you are saying that
> Oracle keeps an up-to-date count for the index (which might make it
> instantaneous?), or whether you are saying it still has to scan the
> index - which can take time if the index is large (therefore not
> instantaneous).
>
> Cheers,
> mark
>
> --
> Mark Mielke <mark@mielke.cc>
>
Oracle scans the index pages, if the b-tree index is on non-nullable
columns, or if the bitmap index is on low-ish cardinality data.
Otherwise, it table scans. MyISAM in MySQL would be an example where a
counter is kept.
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-performance@postgresql.org
Cc: rivers.paul@gmail.com, mark@mark.mielke.cc, tgl@sss.pgh.pa.us, craig_james@emolecules.com
Subject: Re: count * performance issue
In-Reply-To: <47D23C17.7010207@gmail.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox