Re: ANALYZE not working? - Mailing list pgsql-admin

From Tom Lane
Subject Re: ANALYZE not working?
Date
Msg-id 3064.1041887771@sss.pgh.pa.us
Whole thread Raw
In response to ANALYZE not working?  (Jeff Boes <jboes@nexcerpt.com>)
List pgsql-admin
Jeff Boes <jboes@nexcerpt.com> writes:
> This is just way too weird:
> $ psql
> # select count(*) from stat_fetch;
>  count
> --------
>  143243
> (1 row)

> (Big table, two indexes.)

> # analyze stat_fetch;
> ANALYZE

> (That should update all the stats, right?)

> # select relname, reltuples from pg_class
> # where relname = 'stat_fetch';
>   relname   | reltuples
> ------------+-----------
>  stat_fetch |      3419
> (1 row)

> (Wha? Huh?)

Have you done VACUUM FULL on this table in living memory?

The current implementation of ANALYZE can get fooled if the table has
very nonuniform tuple density (eg, lots of empty or near-empty pages
near the beginning, and filled pages near the end).

I'd try "vacuum full verbose stat_fetch" and note whether it shrinks the
table a lot.  (If it does, that suggests that you need more frequent
regular vacuums, and/or larger FSM settings in postgresql.conf.)

            regards, tom lane

pgsql-admin by date:

Previous
From: Ron Mayer
Date:
Subject: Re: ANALYZE not working?
Next
From: mitchell laks
Date:
Subject: repair table? database? how ? neccessary?