Stats update difference between VACUUM ANALYZE and ANALYZE in 9.2?

From: Paul Jones <pbj(at)cmicdo(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Stats update difference between VACUUM ANALYZE and ANALYZE in 9.2?
Date: 2016-09-26 13:32:46
Message-ID: 20160926133246.GA2755@cmicdo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

For a freshly pg_restore'd 9.2 database, would VACUUM ANALYZE update
statistics any better than just an ANALYZE?

After a restore, we ran a bunch of ANALYZEs on each table individually
using GNU 'parallel' (for speed). Many of these tables are child tables
in a partition. Following the ANALYZEs, a join with the parent table
showed all of the child tables scanned sequentially.

After running VACUUM ANALYZE on the whole database, the same join used
index-only scans on the child tables.

An examination of the fine manual implies there may be some difference
(or a documentation conflict?) between running ANALYZE manually on
individual tables and an unqualified ANALYZE on the whole database.

5.9.6:
"If you are using manual VACUUM or ANALYZE commands, don't forget
that you need to run them on each partition individually. A
command like:
ANALYZE measurement;
will only process the master table."

ANALYZE:
"If the table being analyzed has one or more children, ANALYZE
will gather statistics twice: once on the rows of the parent table
only, and a second time on the rows of the parent table with all
of its children. This second set of statistics is needed when
planning queries that traverse the entire inheritance tree. The
autovacuum daemon, however, will only consider inserts or updates
on the parent table itself when deciding whether to trigger
an automatic analyze for that table. If that table is rarely
inserted into or updated, the inheritance statistics will not
be up to date unless you run ANALYZE manually."

Can anyone explain what's going on here?

Thanks,
Paul Jones

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2016-09-26 13:42:12 Re: Stats update difference between VACUUM ANALYZE and ANALYZE in 9.2?
Previous Message Michael Sheaver 2016-09-26 13:30:35 Re: Chante domain type - Postgres 9.2