Re: [PERFORM] Newbie question: ultra fast count(*)

2005-11-28 Thread Merlin Moncure
 I have been reading all this technical talk about costs and such that
 I don't (_yet_) understand.
 
 Now I'm scared... what's the fastest way to do an equivalent of
 count(*) on a table to know how many items it has?

Make sure to analyze the database frequently and check pg_class for
reltuples field.  This gives 0 time approximations of # row in table at
the time of the last analyze.

Many other approaches...check archives.  Also your requirements are
probably not as high as you think they are ;)

Merlin


---(end of broadcast)---
TIP 5: don't forget to increase your free space map settings


Re: [PERFORM] Newbie question: ultra fast count(*)

2005-11-25 Thread Jaime Casanova
On 11/25/05, Rodrigo Madera [EMAIL PROTECTED] wrote:
 I have been reading all this technical talk about costs and such that
 I don't (_yet_) understand.

 Now I'm scared... what's the fastest way to do an equivalent of
 count(*) on a table to know how many items it has?

 Thanks,
 Rodrigo


you really *need* this?

you can do
SELECT reltuples FROM pg_class WHERE relname = 'your_table_name';

but this will give you an estimate... if you want real values you can
make a TRIGGER that maintain a counter in another table

--
regards,
Jaime Casanova
(DBA: DataBase Aniquilator ;)

---(end of broadcast)---
TIP 1: if posting/reading through Usenet, please send an appropriate
   subscribe-nomail command to [EMAIL PROTECTED] so that your
   message can get through to the mailing list cleanly