Joseph Shraibman <jks@selectacast.net> writes:
> Greg Stark wrote:
>> There won't be anything to VACUUM after the insert, but perhaps you still want
>> to run ANALYZE. Note that a plain ANALYZE uses a statistical sample which is
>> much faster, whereas VACUUM ANALYZE has to look at every record anyways so
>> it's slower but produces more accurate statistics. If you don't have
> That is not true. My nightly vacuum analyze clearly is sampling:
> INFO: "tablename": 22102 pages, 30000 rows sampled, 1712934 estimated
> total rows
There is (only) one aspect in which VACUUM ANALYZE will produce more
accurate stats than a standalone ANALYZE: what it stores into
pg_class.reltuples is the true total tuple count produced by the VACUUM
phase, rather than the estimate produced by the ANALYZE phase. What
goes into pg_statistic will be the same in both cases, however, and will
be based on a sample not the whole table.
BTW, a VACUUM just after a table is loaded by INSERT/COPY is not
necessarily useless. It won't reclaim space, there being none to
reclaim, but it will mark all the rows as "known committed", thereby
saving some amount of I/O that would otherwise be incurred by later
transactions.
regards, tom lane