pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: josh@agliodbs.com
Cc: pgsql-performance@postgresql.org, Craig James <craig_james@emolecules.com>
Subject: Re: count * performance issue
Date: Fri, 07 Mar 2008 20:38:15 -0500
Message-ID: <13345.1204940295@sss.pgh.pa.us> (raw)
In-Reply-To: <200803071727.36146.josh@agliodbs.com>
References: <f966c2ee0803052142l6a105678jfe2da92a0d9371@mail.gmail.com>
	<47D00DB2.7040007@emolecules.com>
	<18451.1204824562@sss.pgh.pa.us>
	<200803071727.36146.josh@agliodbs.com>

Josh Berkus <josh@agliodbs.com> writes:
> Tom,
>>> 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.

Well, scanning an index to get a count might be significantly faster
than scanning the main table, but it's hardly "instantaneous".  It's
still going to take time proportional to the table size.

Unless they keep a central counter of the number of index entries;
which would have all the same serialization penalties we've talked
about before...

			regards, tom lane



view thread (62+ messages)  latest in thread

Message-ID: <13345.1204940295@sss.pgh.pa.us>
Permalink:  ../13345.1204940295@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/13345.1204940295@sss.pgh.pa.us

 · 

reply

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: tgl@sss.pgh.pa.us, josh@agliodbs.com, craig_james@emolecules.com
  Subject: Re: count * performance issue
  In-Reply-To: <13345.1204940295@sss.pgh.pa.us>

* 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