meaning of default_statistics_target

Started by Martin Marquesalmost 18 years ago4 messagesgeneral
Jump to latest
#1Martin Marques
martin@marquesminen.com.ar

I'm trying to understand the implications of changing the value of the
STATISTICS of a column with ALTER TABLE, and there are somethings I'm
not understanding correctly.

How much, and which extra statistics information will ANALYZE gather if
I set a higher value for one specific column (maybe one with and index,
and heavily used in SELECT clauses)? If instead of 100 I set a column to
250, which extra data will I see in pg_statistics after an ANALYZE?

Thanks.

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Martin Marques (#1)
Re: meaning of default_statistics_target

Martin Marques <martin@marquesminen.com.ar> writes:

How much, and which extra statistics information will ANALYZE gather if
I set a higher value for one specific column (maybe one with and index,
and heavily used in SELECT clauses)? If instead of 100 I set a column to
250, which extra data will I see in pg_statistics after an ANALYZE?

The target determines the desired size of the histogram and
most-common-values arrays. Increasing it gives you better resolution of
those stats.

Increasing the target also increases the number of rows that ANALYZE
samples to prepare the stats, so you should theoretically get more
accurate stats for the other columns too, even though they'll still get
boiled down to the same array lengths as before.

regards, tom lane

#3Martin Marques
martin@marquesminen.com.ar
In reply to: Tom Lane (#2)
Re: meaning of default_statistics_target

Tom Lane escribió:

Martin Marques <martin@marquesminen.com.ar> writes:

How much, and which extra statistics information will ANALYZE gather if
I set a higher value for one specific column (maybe one with and index,
and heavily used in SELECT clauses)? If instead of 100 I set a column to
250, which extra data will I see in pg_statistics after an ANALYZE?

The target determines the desired size of the histogram and
most-common-values arrays. Increasing it gives you better resolution of
those stats.

Increasing the target also increases the number of rows that ANALYZE
samples to prepare the stats, so you should theoretically get more
accurate stats for the other columns too, even though they'll still get
boiled down to the same array lengths as before.

Is the value measured in some scale, or does it depend on something
internal? What does 1000 mean?

#4Alvaro Herrera
alvherre@2ndquadrant.com
In reply to: Martin Marques (#3)
Re: meaning of default_statistics_target

Martin Marques escribi�:

Is the value measured in some scale, or does it depend on something
internal? What does 1000 mean?

1000 histogram and MCV entries, and also a larger sample:

Increasing the target also increases the number of rows that ANALYZE
samples to prepare the stats, so you should theoretically get more
accurate stats for the other columns too, even though they'll still get
boiled down to the same array lengths as before.

How larger is the sample, I don't know.

--
Alvaro Herrera http://www.CommandPrompt.com/
The PostgreSQL Company - Command Prompt, Inc.