Re: reltuples after vacuum and analyze

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Litao Wu <litaowu(at)yahoo(dot)com>
Cc: pgsql-performance(at)postgresql(dot)org
Subject: Re: reltuples after vacuum and analyze
Date: 2005-01-25 00:26:26
Message-ID: 27553.1106612786@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

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

In response to

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message SpaceBallOne 2005-01-25 01:22:36 Re: poor performance of db?
Previous Message Tatsuo Ishii 2005-01-25 00:21:09 Re: PgPool changes WAS: PostgreSQL clustering VS MySQL