Thread: Column Statistics - How to dertermine for whole database

Column Statistics - How to dertermine for whole database

From
Ow Mun Heng
Date:
Hi,

I finally figure out how come (i think) my analyszing of some specific
tables is taking so freaking long. 12million rows, ~11GB table.

I had some of the columns with the stat level set up to 1000. (this was
previously because I was trying to optimise somethings to make things
faster. ) When the table was small, the analyse of that table went by
pretty fast, until it became bigger, now it's a headache.

So, my investigation found that It was due to the stats level I put into
that column. (normal stat level = 100).

Is there a query to pg_catalog tables to find out which table/column has
the stat level not at default in 1 sweep?

Appreciate any pointers.

Re: Column Statistics - How to dertermine for whole database

From
"Adam Rich"
Date:
> Is there a query to pg_catalog tables to find out which table/column
> has
> the stat level not at default in 1 sweep?

Try this:

select c.relname, a.attname, attstattarget
from pg_catalog.pg_attribute a, pg_catalog.pg_class c,
pg_catalog.pg_namespace n
where a.attrelid = c.oid and c.relnamespace=n.oid
and n.nspname = 'public' and a.attnum > 0

The value "-1" means to use the default (set in postgreql.conf)






Re: Column Statistics - How to dertermine for whole database

From
Ow Mun Heng
Date:
On Wed, 2008-03-12 at 21:33 -0500, Adam Rich wrote:
> select c.relname, a.attname, attstattarget
> from pg_catalog.pg_attribute a, pg_catalog.pg_class c,
> pg_catalog.pg_namespace n
> where a.attrelid = c.oid and c.relnamespace=n.oid
> and n.nspname = 'public' and a.attnum > 0

Funny, that does not work.

note : I did change the nspace value to reflect the DB I'm
using/querying

I've even changed the stat level to 200 (default is 100 or -1)


Re: Column Statistics - How to dertermine for whole database

From
"Scott Marlowe"
Date:
On Wed, Mar 12, 2008 at 8:45 PM, Ow Mun Heng <Ow.Mun.Heng@wdc.com> wrote:
> On Wed, 2008-03-12 at 21:33 -0500, Adam Rich wrote:
>  > select c.relname, a.attname, attstattarget
>  > from pg_catalog.pg_attribute a, pg_catalog.pg_class c,
>  > pg_catalog.pg_namespace n
>  > where a.attrelid = c.oid and c.relnamespace=n.oid
>  > and n.nspname = 'public' and a.attnum > 0
>
>  Funny, that does not work.
>
>  note : I did change the nspace value to reflect the DB I'm
>  using/querying
>
>  I've even changed the stat level to 200 (default is 100 or -1)

The nspname setting setting is for schema, not db name.

Re: Column Statistics - How to dertermine for whole database

From
Ow Mun Heng
Date:
On Wed, 2008-03-12 at 21:40 -0700, Scott Marlowe wrote:
> On Wed, Mar 12, 2008 at 8:45 PM, Ow Mun Heng <Ow.Mun.Heng@wdc.com> wrote:
> > On Wed, 2008-03-12 at 21:33 -0500, Adam Rich wrote:
> >  > select c.relname, a.attname, attstattarget
> >  > from pg_catalog.pg_attribute a, pg_catalog.pg_class c,
> >  > pg_catalog.pg_namespace n
> >  > where a.attrelid = c.oid and c.relnamespace=n.oid
> >  > and n.nspname = 'public' and a.attnum > 0
> >
> >  Funny, that does not work.
> >
> >  note : I did change the nspace value to reflect the DB I'm
> >  using/querying
> >
> >  I've even changed the stat level to 200 (default is 100 or -1)
>
> The nspname setting setting is for schema, not db name.


select c.relname, a.attname, attstattarget
from pg_catalog.pg_attribute a, pg_catalog.pg_class c,
pg_catalog.pg_namespace n
where a.attrelid = c.oid and c.relnamespace=n.oid
and n.nspname = 'xmms' and a.attnum > 0 and attstattarget <> -1;

This works now.
The clarification on it being the schema name was useful.
Thanks.