Litao Wu <litaowu(at)yahoo(dot)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