Re: Why Select Count(*) from table - took over 20 minutes? - Mailing list pgsql-general

From Merlin Moncure
Subject Re: Why Select Count(*) from table - took over 20 minutes?
Date
Msg-id AANLkTin+XdaRAd+D-3D3Uvj5Kd0gr8TfYn2oTfOHcpiT@mail.gmail.com
Whole thread Raw
In response to Re: Why Select Count(*) from table - took over 20 minutes?  (Ozz Nixon <ozznixon@gmail.com>)
List pgsql-general
On Thu, Oct 28, 2010 at 11:36 AM, Ozz Nixon <ozznixon@gmail.com> wrote:
> How/where do I query this?
>
> My script does not need a 100% accurate count - just a recently valid count - so I can verify the web crawlers are
stillcrawling :-) 

you can do this:
select reltuples from pg_class where relname = 'your_table' and relkind = 'r';

that will give you accurate count as of the last analyze, which is
going to be driven by table usage and/or manual analyze.   Probably
much better in your particular case is to do this:

select * from pg_stat_all_tables where relname = 'your_table';

and look at the n_tup_ins, del, etc.  and make sure they are changing
(those numbers are reset when server resets, fyi).

merlin

pgsql-general by date:

Previous
From: ludwig@kni-online.de
Date:
Subject: Re: PostGIS return multiple points
Next
From: "Daniel Verite"
Date:
Subject: Re: Should PQconsumeInput/PQisBusy be expensive to use?