Thread: [PERFORM] change sample size for statistics

[PERFORM] change sample size for statistics

From
Willy-Bas Loos
Date:
Hi,

is there a way to change the sample size for statistics (that analyze gathers)?
It is said to be 10%. i would like to raise that, because we are getting bas estimations for n_distinct.

Cheers,

WBL

--
"Patriotism is the conviction that your country is superior to all others because you were born in it." -- George Bernard Shaw

Re: [PERFORM] change sample size for statistics

From
Willy-Bas Loos
Date:


On Fri, Jun 10, 2011 at 9:58 PM, Josh Berkus <josh@agliodbs.com> wrote:
It's not 10%.  We use a fixed sample size, which is configurable on the
system, table, or column basis.

It seems that you are referring to "alter column set statistics" and "default_statistics_target", which are the number of percentiles in the histogram  (and MCV's) .
I mean the number of records that are scanned by analyze to come to the statistics for the planner, especially n_disctict.


On Fri, Jun 10, 2011 at 10:06 PM, Nathan Boley <npboley@gmail.com> wrote:
If you need to fix ndistinct, a better approach may be to do it manually.

That would be nice, but how do i prevent the analyzer to overwrite n_distinct without blocking the generation of new histogram values etc for that column?

We use version 8.4 at the moment (on debian squeeze).

Cheers,

WBL
--
"Patriotism is the conviction that your country is superior to all others because you were born in it." -- George Bernard Shaw

Re: [PERFORM] change sample size for statistics

From
Robert Haas
Date:
On Mon, Jun 13, 2011 at 6:33 PM, Willy-Bas Loos <willybas@gmail.com> wrote:
> On Fri, Jun 10, 2011 at 9:58 PM, Josh Berkus <josh@agliodbs.com> wrote:
>>
>> It's not 10%.  We use a fixed sample size, which is configurable on the
>> system, table, or column basis.
>
> It seems that you are referring to "alter column set statistics" and
> "default_statistics_target", which are the number of percentiles in the
> histogram  (and MCV's) .
> I mean the number of records that are scanned by analyze to come to the
> statistics for the planner, especially n_disctict.

In 9.0+ you can do ALTER TABLE .. ALTER COLUMN .. SET (n_distinct = ...);

--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company