| From: | Jaime Casanova <systemguards(at)gmail(dot)com> |
|---|---|
| To: | Rodrigo Madera <rodrigo(dot)madera(at)gmail(dot)com> |
| Cc: | pgsql-performance(at)postgresql(dot)org |
| Subject: | Re: Newbie question: ultra fast count(*) |
| Date: | 2005-11-25 19:40:06 |
| Message-ID: | c2d9e70e0511251140x5f2a6c2ah6fc81d88fcfb2213@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-performance |
On 11/25/05, Rodrigo Madera <rodrigo(dot)madera(at)gmail(dot)com> 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 ;)
| From | Date | Subject | |
|---|---|---|---|
| Next Message | David Lang | 2005-11-26 14:28:50 | Re: Open request for benchmarking input |
| Previous Message | Rodrigo Madera | 2005-11-25 19:36:35 | Newbie question: ultra fast count(*) |