Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Can someone explain ALTER TABLE SET STATISTICS?

0 views
Skip to first unread message

Mladen Gogala

unread,
Nov 16, 2009, 1:09:24 PM11/16/09
to
The documentation of this command is extremely unclear and vague? What
does the integer argument taken by this command represent? My guess is
that it is determining the percentage of the table to inspect for
calculating the statistics? If that is so, why is it integer?

--
http://mgogala.byethost5.com

Matthew Woodcraft

unread,
Nov 16, 2009, 1:59:04 PM11/16/09
to
Mladen Gogala <n...@email.here.invalid> wrote:

> The documentation of this command is extremely unclear and vague? What
> does the integer argument taken by this command represent? My guess is
> that it is determining the percentage of the table to inspect for
> calculating the statistics? If that is so, why is it integer?

What it controls directly is the level of detail used to store summary
statistics after the table has been inspected.

It determines two things: the number of 'most common values' to store
statistics for, and the number of buckets to store statistics for in
the value frequency histogram.

Section 14.2 explains this, and there's a detailed walkthrough of the
algorithm that uses it in 55.1 (in the 8.4 docs).


I believe it does also indirectly determine the percentage of the table
inspected; that is, ANALYZE samples enough rows to get accurate
statistics at the level of detail requested. I don't think this
percentage is directly tunable.

-M-

Mladen Gogala

unread,
Nov 16, 2009, 2:45:48 PM11/16/09
to

Ah, I got it:

"The amount of information stored in pg_statistic by ANALYZE, in
particular the maximum number of entries in the most_common_vals and
histogram_bounds arrays for each column, can be set on a column-by-column
basis using the ALTER TABLE SET STATISTICS command, or globally by
setting the default_statistics_target configuration variable."

It's the size of histogram for every column! Thanks a lot for your help.

--
http://mgogala.byethost5.com

0 new messages