Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Data Bases > Pgsql Performance > Re: count * per...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 1 Topic 3859 of 4424
Post > Topic >>

Re: count * performance issue

by darcy@[EMAIL PROTECTED] ("D'Arcy J.M. Cain") Mar 6, 2008 at 11:31 AM

On Thu, 06 Mar 2008 07:28:50 -0800
Craig James <craig_james@[EMAIL PROTECTED]
> wrote:
> In the 3 years I've been using Postgres, the problem of count()
performance has come up more times than I can recall, and each time the
answer is, "It's a sequential scan -- redesign your application."
> 
> My question is: What do the other databases do that Postgres can't do,
and why not?
> 
> Count() on Oracle and MySQL is almost instantaneous, even for very large
tables. So why can't Postgres do what they do?

It's a tradeoff.  The only way to get that information quickly is to
maintain it internally when you insert or delete a row.  So when do you
want to take your hit.  It sounds like Oracle has made this decision
for you.  In PostgreSQL you can use triggers and rules to manage this
information if you need it.  You can even do stuff like track how many
of each type of something you have.  That's something you can't do if
your database engine has done a generic speedup for you.  You would
still have to create your own table for something like that and then
you get the hit twice.

-- 
D'Arcy J.M. Cain <darcy@[EMAIL PROTECTED]
>         |  Democracy is three wolves
http://www.druid.net/darcy/
               |  and a sheep voting on
+1 416 425 1212     (DoD#0082)    (eNTP)   |  what's for dinner.

--
Sent via pgsql-performance mailing list (pgsql-performance@[EMAIL PROTECTED]
)
To make changes to your subscription:
http://mail.postgresql.org/mj/mj_wwwusr?domain=postgresql.org&extra=pgsql-performance
 




 1 Posts in Topic:
Re: count * performance issue
darcy@[EMAIL PROTECTED]   2008-03-06 11:31:44 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Mon Dec 1 8:22:37 CST 2008.