| From: | Ron Johnson <ron(dot)l(dot)johnson(at)cox(dot)net> | 
|---|---|
| To: | pgsql-general(at)postgresql(dot)org | 
| Subject: | Re: Table Stats | 
| Date: | 2003-08-01 14:14:31 | 
| Message-ID: | 1059747271.7505.582.camel@haggis | 
| Views: | Whole Thread | Raw Message | Download mbox | Resend email | 
| Thread: | |
| Lists: | pgsql-general | 
On Thu, 2003-07-31 at 23:23, Dennis Gearon wrote:
> It will only be at a given point in time, since datasbases are by
> design, realtime/concurrent applications.
> 
> do:
> 
> SELECT COUNT(*) FROM table_name;
> 
> Should give you what you want.
It'll give him what he wants, but not quickly, if it's a 10/20/etc
M row table.
One hack is:
CREATE TABLE T_CARDINALITY (
RELATION_NAME    CHAR(31) PRIMARY KEY,
CARDINALITY      BIGINT );
Then put ON INSERT/ON DELETE triggers on each table you want to
track that increment/decrement T_CARDINALITY.CARDINALITY at the
appropriate moment.
> Jeff Davidson wrote:
> 
> > Hi!
> > 
> > Is there any quick way to determine how many rows exist in a given table?
-- 
+-----------------------------------------------------------------+
| Ron Johnson, Jr.        Home: ron(dot)l(dot)johnson(at)cox(dot)net             |
| Jefferson, LA  USA                                              |
|                                                                 |
| "I'm not a vegetarian because I love animals, I'm a vegetarian  |
|  because I hate vegetables!"                                    |
|    unknown                                                      |
+-----------------------------------------------------------------+
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Ron Johnson | 2003-08-01 14:19:15 | Re: UPDATE sql question | 
| Previous Message | Tom Lane | 2003-08-01 14:05:53 | Re: Comments in .sql files |