Tom Lane wrote:
Craig James <[EMAIL PROTECTED]> writes:
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.

My experience doesn't match this claim.  When I ported my application from 
Oracle to Postgres, this was the single biggest performance problem.  count() 
in Oracle was always very fast.  We're not talking about a 20% or 50% 
difference, we're talking about a small fraction of a second (Oracle) versus a 
minute (Postgres) -- something like two or three orders of magnitude.

It may be that Oracle has a way to detect when there's no transaction and use a 
faster method.  If so, this was a clever optimization -- in my experience, that 
represents the vast majority of the times you want to use count().  It's not 
very useful to count the rows of a table that many apps are actively modifying 
since the result may change the moment your transaction completes.  Most of the 
time when you use count(), it's because you're the only one modifying the 
table, so the count will be meaningful.

Craig


--
Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-performance

Reply via email to