Re: [SQLObject] PostgreSQL: costly count
SQLObject is a Python ORM.
Brought to you by:
ianbicking,
phd
|
From: Sidnei da S. <si...@aw...> - 2003-12-04 17:55:33
|
| >>>
| example:
| On our message boards each post is a row. The powers that be like to
| know
| how many posts there are total (In addition to 'today')-
| select count(*) from posts is how it has been
| done on our informix db. With our port to PG I instead select reltuples
| pg_class.
| <<<
|
| pg_class is a mysterious table indeed, but it's got lots of good magic
| in it. (I'm not even sure if this is the right magic, but worth a try)
Humm... It seems to be the right one, but how can I measure which one
is faster? In my 11k table, both are blazingly fast :)
zope3=# select reltuples from pg_class where relname = 'aliquot';
reltuples
-----------
11801
(1 row)
zope3=# select count(*) from aliquot;
count
-------
11801
(1 row)
--
Sidnei da Silva <si...@aw...>
http://awkly.org - dreamcatching :: making your dreams come true
http://plone.org/about/team#dreamcatcher
The trouble with computers is that they do what you tell them, not what
you want.
-- D. Cohen
|