Re: reltuples after vacuum and analyze - Mailing list pgsql-performance

From Tom Lane
Subject Re: reltuples after vacuum and analyze
Date
Msg-id 27553.1106612786@sss.pgh.pa.us
Whole thread Raw
In response to reltuples after vacuum and analyze  (Litao Wu <litaowu@yahoo.com>)
Responses Re: reltuples after vacuum and analyze  (Litao Wu <litaowu@yahoo.com>)
List pgsql-performance
Litao Wu <litaowu@yahoo.com> writes:
> I noticed that reltuples are way off if
> I vacuum the table and analyze the table.
> And the data (296901) after vacuum seems
> accurate while
> the reltuples (1.90744e+06)
> after anlayze is too wrong.

VACUUM derives an exact count because it scans the whole table.  ANALYZE
samples just a subset of the table and extrapolates.  It would appear
that you've got radically different tuple densities in different parts
of the table, and that's confusing ANALYZE.

> My PG version is 7.3.2 (I know it is old).

8.0's ANALYZE uses a new sampling method that we think is less prone
to this error, though of course any sampling method will fail some of
the time.

            regards, tom lane

pgsql-performance by date:

Previous
From: Tatsuo Ishii
Date:
Subject: Re: PgPool changes WAS: PostgreSQL clustering VS MySQL
Next
From: "SpaceBallOne"
Date:
Subject: Re: poor performance of db?